einhorn 0.8.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +10 -0
  3. data/{LICENSE → LICENSE.txt} +0 -0
  4. data/README.md +5 -36
  5. data/einhorn.gemspec +23 -21
  6. data/example/pool_worker.rb +2 -2
  7. data/example/thin_example +8 -8
  8. data/example/time_server +5 -5
  9. data/lib/einhorn/client.rb +8 -8
  10. data/lib/einhorn/command/interface.rb +92 -98
  11. data/lib/einhorn/command.rb +76 -85
  12. data/lib/einhorn/compat.rb +7 -7
  13. data/lib/einhorn/event/abstract_text_descriptor.rb +31 -35
  14. data/lib/einhorn/event/ack_timer.rb +2 -2
  15. data/lib/einhorn/event/command_server.rb +7 -9
  16. data/lib/einhorn/event/connection.rb +1 -3
  17. data/lib/einhorn/event/loop_breaker.rb +2 -1
  18. data/lib/einhorn/event/persistent.rb +2 -2
  19. data/lib/einhorn/event/timer.rb +4 -4
  20. data/lib/einhorn/event.rb +19 -19
  21. data/lib/einhorn/prctl.rb +2 -2
  22. data/lib/einhorn/prctl_linux.rb +13 -14
  23. data/lib/einhorn/safe_yaml.rb +17 -0
  24. data/lib/einhorn/version.rb +1 -1
  25. data/lib/einhorn/worker.rb +26 -30
  26. data/lib/einhorn/worker_pool.rb +9 -9
  27. data/lib/einhorn.rb +120 -125
  28. metadata +33 -117
  29. data/.gitignore +0 -17
  30. data/.travis.yml +0 -10
  31. data/CONTRIBUTORS +0 -6
  32. data/Gemfile +0 -11
  33. data/History.txt +0 -4
  34. data/README.md.in +0 -94
  35. data/Rakefile +0 -27
  36. data/test/_lib.rb +0 -12
  37. data/test/integration/_lib/fixtures/env_printer/env_printer.rb +0 -26
  38. data/test/integration/_lib/fixtures/exit_during_upgrade/exiting_server.rb +0 -23
  39. data/test/integration/_lib/fixtures/exit_during_upgrade/upgrade_reexec.rb +0 -6
  40. data/test/integration/_lib/fixtures/pdeathsig_printer/pdeathsig_printer.rb +0 -29
  41. data/test/integration/_lib/fixtures/signal_timeout/sleepy_server.rb +0 -23
  42. data/test/integration/_lib/fixtures/upgrade_project/upgrading_server.rb +0 -24
  43. data/test/integration/_lib/helpers/einhorn_helpers.rb +0 -148
  44. data/test/integration/_lib/helpers.rb +0 -4
  45. data/test/integration/_lib.rb +0 -6
  46. data/test/integration/pdeathsig.rb +0 -26
  47. data/test/integration/startup.rb +0 -31
  48. data/test/integration/upgrading.rb +0 -204
  49. data/test/unit/_lib/bad_worker.rb +0 -7
  50. data/test/unit/_lib/sleep_worker.rb +0 -5
  51. data/test/unit/einhorn/client.rb +0 -88
  52. data/test/unit/einhorn/command/interface.rb +0 -49
  53. data/test/unit/einhorn/command.rb +0 -135
  54. data/test/unit/einhorn/event.rb +0 -89
  55. data/test/unit/einhorn/worker_pool.rb +0 -39
  56. data/test/unit/einhorn.rb +0 -96
data/test/unit/einhorn.rb DELETED
@@ -1,96 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../_lib'))
2
-
3
- require 'einhorn'
4
-
5
- class EinhornTest < EinhornTestCase
6
- describe "when sockifying" do
7
- after do
8
- Einhorn::State.sockets = {}
9
- end
10
-
11
- it "correctly parses srv: arguments" do
12
- cmd = ['foo', 'srv:1.2.3.4:123,llama,test', 'bar']
13
- Einhorn.expects(:bind).once.with('1.2.3.4', '123', ['llama', 'test']).returns([4, 10087])
14
-
15
- Einhorn.socketify!(cmd)
16
-
17
- assert_equal(['foo', '4', 'bar'], cmd)
18
- end
19
-
20
- it "correctly parses --opt=srv: arguments" do
21
- cmd = ['foo', '--opt=srv:1.2.3.4:456', 'baz']
22
- Einhorn.expects(:bind).once.with('1.2.3.4', '456', []).returns([5, 10088])
23
-
24
- Einhorn.socketify!(cmd)
25
-
26
- assert_equal(['foo', '--opt=5', 'baz'], cmd)
27
- end
28
-
29
- it "uses the same fd number for the same server spec" do
30
- cmd = ['foo', '--opt=srv:1.2.3.4:8910', 'srv:1.2.3.4:8910']
31
- Einhorn.expects(:bind).once.with('1.2.3.4', '8910', []).returns([10, 10089])
32
-
33
- Einhorn.socketify!(cmd)
34
-
35
- assert_equal(['foo', '--opt=10', '10'], cmd)
36
- end
37
- end
38
-
39
- describe '.update_state' do
40
- it 'correctly updates keys to match new default state hash' do
41
- Einhorn::State.stubs(:default_state).returns(:baz => 23, :foo => 1)
42
- old_state = {:foo => 2, :bar => 2}
43
-
44
- updated_state, message = Einhorn.update_state(Einhorn::State, 'einhorn', old_state)
45
- assert_equal({:baz => 23, :foo => 2}, updated_state)
46
- assert_match(/State format for einhorn has changed/, message)
47
- end
48
-
49
- it 'does not change the state if the format has not changed' do
50
- Einhorn::State.stubs(:default_state).returns(:baz => 23, :foo => 1)
51
- old_state = {:baz => 14, :foo => 1234}
52
-
53
- updated_state, message = Einhorn.update_state(Einhorn::State, 'einhorn', old_state)
54
- assert_equal({:baz => 14, :foo => 1234}, updated_state)
55
- assert(message.nil?)
56
- end
57
- end
58
-
59
- describe ".preload" do
60
- before do
61
- Einhorn::State.preloaded = false
62
- end
63
-
64
- it "updates preload on success" do
65
- Einhorn.stubs(:set_argv).returns
66
- # preloads the sleep worker since it has einhorn main
67
- Einhorn::State.path = "#{__dir__}/_lib/sleep_worker.rb"
68
- assert_equal(false, Einhorn::State.preloaded)
69
- Einhorn.preload
70
- assert_equal(true, Einhorn::State.preloaded)
71
- # Attempt another preload
72
- Einhorn.preload
73
- assert_equal(true, Einhorn::State.preloaded)
74
- end
75
-
76
- it "updates preload to failed with previous success" do
77
- Einhorn.stubs(:set_argv).returns
78
- Einhorn::State.path = "#{__dir__}/_lib/sleep_worker.rb"
79
- assert_equal(false, Einhorn::State.preloaded)
80
- Einhorn.preload
81
- assert_equal(true, Einhorn::State.preloaded)
82
- # Change path to bad worker and preload again, should be false
83
- Einhorn::State.path = "#{__dir__}/_lib/bad_worker.rb"
84
- Einhorn.preload
85
- assert_equal(false, Einhorn::State.preloaded)
86
- end
87
-
88
- it "preload is false after failing" do
89
- Einhorn.stubs(:set_argv).returns
90
- Einhorn::State.path = "#{__dir__}/bad_worker.rb"
91
- assert_equal(false, Einhorn::State.preloaded)
92
- Einhorn.preload
93
- assert_equal(false, Einhorn::State.preloaded)
94
- end
95
- end
96
- end