Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #93 from WeTransfer/cleanup
Browse files Browse the repository at this point in the history
Cleanup some stuff and decrease a logs noise in production
  • Loading branch information
dsnipe authored Mar 30, 2017
2 parents f2a0d8e + 2775fb0 commit c708535
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 56 deletions.
3 changes: 0 additions & 3 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ config :phoenix, :generators,
config :xperiments, :cors,
origin: "*"

config :xperiments, :seed,
applications: [{"web", %{url: "http://lvh.me:5000"}}]

config :ex_rated, :timeout, 1_800_000

config :xperiments, :js_config,
Expand Down
19 changes: 0 additions & 19 deletions lib/release_tasks.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,6 @@ defmodule Xperiments.ReleaseTasks do
:init.stop()
end

def seed do
do_preparations()

# Run migrations
Enum.each(@repos, &run_migrations_for/1)

# Run the seed script if it exists
seed_script = seed_path(:xperiments)
if File.exists?(seed_script) do
IO.puts "Running seed script.."
Code.eval_file(seed_script)
end

# Signal shutdown
IO.puts "Success!"
:init.stop()
end

defp run_migrations_for(repo) do
IO.puts "Running migrations for #{repo}"
Ecto.Migrator.run(repo, migrations_path(:xperiments), :up, all: true)
Expand All @@ -58,5 +40,4 @@ defmodule Xperiments.ReleaseTasks do
end

defp migrations_path(app), do: Application.app_dir(app, "priv/repo/migrations")
defp seed_path(app), do: Path.join(Application.app_dir(app, "priv/repo/"), "seed.exs")
end
8 changes: 1 addition & 7 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,8 @@ defmodule Xperiments.Mixfile do
{:mock, "~> 0.2.0", only: :test}]
end

# Aliases are shortcuts or tasks specific to the current project.
# For example, to create, migrate and run the seeds file at once:
#
# $ mix ecto.setup
#
# See the documentation for `Mix` for more info on aliases.
defp aliases do
["ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
["ecto.setup": ["ecto.create", "ecto.migrate"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
"test": ["ecto.create --quiet", "ecto.migrate", "test"]]
end
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"remote_ip": {:hex, :remote_ip, "0.1.3", "9175e63ce23eece9253bdd17edbd2262bd91c5b700987f6ce0044e504ba42089", [:mix], [{:combine, "~> 0.9.2", [hex: :combine, optional: false]}, {:inet_cidr, "~> 1.0", [hex: :inet_cidr, optional: false]}, {:plug, "~> 1.2", [hex: :plug, optional: false]}]},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
"timex": {:hex, :timex, "3.1.8", "a32f636c4260dd7515a3767be3d3a163dc09d15f0e9e689254b7bab152b29209", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]},
"tzdata": {:hex, :tzdata, "0.5.10", "087e8dfe8c0283473115ad8ca6974b898ecb55ca5c725427a142a79593391e90", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]},
"tzdata": {:hex, :tzdata, "0.5.11", "3d5469a9f46bdf4a8760333dbdabdcc4751325035c454b10521f71e7c611ae50", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]},
"ueberauth": {:hex, :ueberauth, "0.4.0", "bc72d5e5a7bdcbfcf28a756e34630816edabc926303bdce7e171f7ac7ffa4f91", [:mix], [{:plug, "~> 1.2", [hex: :plug, optional: false]}]},
"ueberauth_google": {:hex, :ueberauth_google, "0.5.0", "49b6dd60cc2a4b060767481df04528c6cd6de2236b64d6dbe4aa02d1058ff957", [:mix], [{:oauth2, "~> 0.8", [hex: :oauth2, optional: false]}, {:ueberauth, "~> 0.4", [hex: :ueberauth, optional: false]}]},
"uuid": {:hex, :uuid, "1.1.6", "4927232f244e69c6e255643014c2d639dad5b8313dc2a6976ee1c3724e6ca60d", [:mix], []}}
7 changes: 0 additions & 7 deletions priv/repo/seeds.exs

This file was deleted.

3 changes: 0 additions & 3 deletions rel/commands/seed.sh

This file was deleted.

3 changes: 1 addition & 2 deletions rel/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ environment :prod do
set cookie: System.get_env("NODE_COOKIE")

set commands: [
"migrate": "rel/commands/migrate.sh",
"seed": "rel/commands/seed.sh"
"migrate": "rel/commands/migrate.sh"
]
end

Expand Down
7 changes: 0 additions & 7 deletions test/assigner/event_subscriber_test.exs

This file was deleted.

13 changes: 8 additions & 5 deletions test/assigner/experiment_supervisor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ defmodule Xperiments.Assigner.ExperimentSupervisorTest do
end

test "change a state to 'terminated' in a DB when trying to load invalid experiment" do
exp = insert(:experiment, state: "running", end_date: Timex.shift(Timex.now, days: -1))
:error = ExperimentSupervisor.start_experiment(exp)
:timer.sleep 30
db_exp = Xperiments.Repo.get!(Xperiments.Experiment, exp.id)
assert db_exp.state == "terminated"
err_fun = fn ->
exp = insert(:experiment, state: "running", end_date: Timex.shift(Timex.now, days: -1))
:error = ExperimentSupervisor.start_experiment(exp)
:timer.sleep 30
db_exp = Xperiments.Repo.get!(Xperiments.Experiment, exp.id)
assert db_exp.state == "terminated"
end
assert capture_log(err_fun) =~ "Given experiment is not started"
end

# test "returning pids of children in order sorted by priority" do
Expand Down
5 changes: 3 additions & 2 deletions test/assigner/experiment_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ defmodule Xperiments.Assigner.ExperimentTest do
app = insert(:application, name: "web")
excluded_exp = insert(:experiment, application: app)
exp =
insert(:experiment, state: "running", exclusions: [excluded_exp], rules: Xperiments.Factory.rules_1)
insert(:experiment, state: "running", max_users: 5, exclusions: [excluded_exp], rules: Xperiments.Factory.rules_1)
exp = Map.merge(exp, %{exclusions: Xperiments.Exclusion.for_experiment(exp.id)})
ExperimentSupervisor.start_experiment(exp)
[exp: exp, excluded_exp: excluded_exp]
Expand Down Expand Up @@ -119,10 +119,11 @@ defmodule Xperiments.Assigner.ExperimentTest do

test "termination of an expeiment if reached 'max_users' limit", context do
{:ok, state} = Experiment.init(context.exp)
Enum.scan(0..101, state, fn _, state ->
Enum.scan(0..4, state, fn _, state ->
{:noreply, new_state} = Experiment.handle_cast({:inc_impression, "any_var_id"}, state)
new_state
end)
assert_receive :end_experiment
:timer.sleep(200)
end
end

0 comments on commit c708535

Please sign in to comment.