Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice on test startup times #17

Closed
jc00ke opened this issue Nov 28, 2018 · 7 comments
Closed

Advice on test startup times #17

jc00ke opened this issue Nov 28, 2018 · 7 comments

Comments

@jc00ke
Copy link

jc00ke commented Nov 28, 2018

First off, thanks for veil! It's pretty much exactly what I need for this project.

One sticky point is that Quantum adds a significant delay to starting up the app when in test mode. I'm seeing upwards of 5s just to boot Quantum up. I'm wondering if you have any suggestions as to how to alleviate that?

@zanderxyz
Copy link
Owner

Hi Jesse,

I can think of a workaround but it's a bit messy, there must be a better way. I'll raise an issue and ask the Quantum contributors.

My workaround would involve:

  1. Update the Veil mix file to only load Quantum if in :dev or :prod.
    {:quantum, "~> 2.3", only: [:dev, :prod]},
    This change by itself will cause mix test to crash as Quantum.Scheduler can no longer be found.

  2. Create a dummy Quantum.Scheduler module that is empty and only load it if in :test environment:
    {:quantum, path: "/your_path/quantum", only: :test} mix test` will still crash because the Veil app is trying to start it's Scheduler and failing.

  3. Add config :veil, :environment, Mix.env() to your config.exs
    Just so the app knows what environment it's in when it is running.

  4. Update the veil.ex file inside the Veil repo to only start the Veil Scheduler if not in :test environment:

# delete worker(Veil.Scheduler, []), from row 13

# change the supervisor start function on row 46 to:
Supervisor.start_link(add_scheduler(children), opts)

# add this lower down
defp add_scheduler(children) do
    import Supervisor.Spec, only: [worker: 2]

    if Application.get_env(:veil, :environment) != :test do
      [worker(Veil.Scheduler, []) | children]
    else
      children
    end
  end

This should work - if you're desperate you can try now. But I think there must be a better way.

Will get back to you.

@zanderxyz
Copy link
Owner

The issue I raised:
quantum-elixir/quantum-core#385

@zanderxyz
Copy link
Owner

Hang on, I have a much simpler solution - just steps 3 and 4 above should work for this. I will see if it works on my side first.

@zanderxyz
Copy link
Owner

Simpler solution doesn't work unfortunately, as swarm still gets started by Quantum. The longer one should though, if you are desperate.

@jc00ke
Copy link
Author

jc00ke commented Nov 28, 2018

Thanks for looking into this @zanderxyz! I'm not that desperate... yet, but would love to figure out a way to gracefully handle this.

@zanderxyz
Copy link
Owner

@jc00ke Limited traction in my search so far. For now I have pushed an update as v0.2.1 that doesn't start the Veil scheduler in the test environment. Should give a partial, if not full, speedup.

Give it a try and let me know?

@jc00ke
Copy link
Author

jc00ke commented Dec 3, 2018

Yes! Updating and setting config :veil, :environment, Mix.env() shaved off the 5s startup time. Thank you!

@jc00ke jc00ke closed this as completed Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants