jettywrapper 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.gitmodules +0 -3
- data/.rspec +1 -0
- data/.travis.yml +16 -0
- data/CONTRIBUTING.md +113 -0
- data/Gemfile +5 -1
- data/History.txt +25 -0
- data/LICENSE +1086 -0
- data/README.textile +30 -60
- data/Rakefile +14 -10
- data/config/jetty.yml +5 -4
- data/gemfiles/rails4.1.gemfile +10 -0
- data/gemfiles/rails4.2.beta.gemfile +10 -0
- data/jettywrapper.gemspec +8 -15
- data/lib/jettywrapper/version.rb +3 -1
- data/lib/jettywrapper.rb +344 -217
- data/lib/tasks/jettywrapper.rake +17 -1
- data/spec/lib/jettywrapper_integration_spec.rb +49 -26
- data/spec/lib/jettywrapper_spec.rb +332 -78
- data/spec/spec_helper.rb +19 -5
- metadata +116 -178
- data/.rvmrc +0 -1
data/lib/tasks/jettywrapper.rake
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
require 'yaml'
|
|
3
3
|
|
|
4
4
|
namespace :jetty do
|
|
5
|
+
JETTY_DIR = 'jetty'
|
|
6
|
+
|
|
7
|
+
desc "download the jetty zip file"
|
|
8
|
+
task :download do
|
|
9
|
+
Jettywrapper.download
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "unzip the downloaded jetty archive"
|
|
13
|
+
task :unzip do
|
|
14
|
+
Jettywrapper.unzip
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "remove the jetty directory and recreate it"
|
|
18
|
+
task :clean do
|
|
19
|
+
Jettywrapper.clean
|
|
20
|
+
end
|
|
5
21
|
|
|
6
22
|
desc "Return the status of jetty"
|
|
7
23
|
task :status => :environment do
|
|
@@ -22,7 +38,7 @@ namespace :jetty do
|
|
|
22
38
|
end
|
|
23
39
|
|
|
24
40
|
desc "Restarts jetty"
|
|
25
|
-
task :restart do
|
|
41
|
+
task :restart => :environment do
|
|
26
42
|
Jettywrapper.stop(JETTY_CONFIG)
|
|
27
43
|
Jettywrapper.start(JETTY_CONFIG)
|
|
28
44
|
end
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
require
|
|
2
|
-
require File.join(File.dirname(__FILE__), "/../../lib/jettywrapper")
|
|
1
|
+
require 'spec_helper'
|
|
3
2
|
require 'rubygems'
|
|
4
|
-
require 'ruby-debug'
|
|
5
3
|
require 'uri'
|
|
6
4
|
require 'net/http'
|
|
5
|
+
require 'socket'
|
|
7
6
|
|
|
8
7
|
module Hydra
|
|
9
8
|
describe Jettywrapper do
|
|
10
9
|
context "integration" do
|
|
11
10
|
before(:all) do
|
|
12
11
|
$stderr.reopen("/dev/null", "w")
|
|
12
|
+
Jettywrapper.logger.level=3
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "starts" do
|
|
16
16
|
jetty_params = {
|
|
17
|
-
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
|
|
17
|
+
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
|
|
18
|
+
:startup_wait => 90,
|
|
19
|
+
:java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
|
|
20
|
+
:jetty_port => TEST_JETTY_PORTS.first
|
|
18
21
|
}
|
|
19
22
|
Jettywrapper.configure(jetty_params)
|
|
20
23
|
ts = Jettywrapper.instance
|
|
@@ -24,11 +27,10 @@ module Hydra
|
|
|
24
27
|
ts.logger.debug "Jetty started from rspec at #{ts.pid}"
|
|
25
28
|
pid_from_file = File.open( ts.pid_path ) { |f| f.gets.to_i }
|
|
26
29
|
ts.pid.should eql(pid_from_file)
|
|
27
|
-
sleep 30 # give jetty time to start
|
|
28
30
|
|
|
29
31
|
# Can we connect to solr?
|
|
30
32
|
require 'net/http'
|
|
31
|
-
response = Net::HTTP.get_response(URI.parse("http://localhost:
|
|
33
|
+
response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/"))
|
|
32
34
|
response.code.should eql("200")
|
|
33
35
|
ts.stop
|
|
34
36
|
|
|
@@ -36,51 +38,72 @@ module Hydra
|
|
|
36
38
|
|
|
37
39
|
it "won't start if it's already running" do
|
|
38
40
|
jetty_params = {
|
|
39
|
-
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty")
|
|
41
|
+
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
|
|
42
|
+
:startup_wait => 90,
|
|
43
|
+
:java_opts => ["-Xmx256m", '-XX:MaxPermSize=256m'],
|
|
44
|
+
:jetty_port => TEST_JETTY_PORTS.first
|
|
40
45
|
}
|
|
41
46
|
Jettywrapper.configure(jetty_params)
|
|
42
47
|
ts = Jettywrapper.instance
|
|
43
48
|
ts.logger.debug "Stopping jetty from rspec."
|
|
44
49
|
ts.stop
|
|
45
50
|
ts.start
|
|
46
|
-
sleep 30
|
|
47
51
|
ts.logger.debug "Jetty started from rspec at #{ts.pid}"
|
|
48
|
-
response = Net::HTTP.get_response(URI.parse("http://localhost:
|
|
52
|
+
response = Net::HTTP.get_response(URI.parse("http://localhost:#{jetty_params[:jetty_port]}/solr/"))
|
|
49
53
|
response.code.should eql("200")
|
|
50
54
|
lambda { ts.start }.should raise_exception(/Server is already running/)
|
|
51
55
|
ts.stop
|
|
52
56
|
end
|
|
53
57
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
describe "is_port_in_use?" do
|
|
59
|
+
describe "when a server is running on the port" do
|
|
60
|
+
before do
|
|
61
|
+
@s = TCPServer.new('127.0.0.1', TEST_JETTY_PORTS.last)
|
|
62
|
+
end
|
|
63
|
+
after do
|
|
64
|
+
@s.close
|
|
65
|
+
end
|
|
66
|
+
it "can check to see whether a port is already in use" do
|
|
67
|
+
Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last).should eql(true)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
it "should be false when nothing is running" do
|
|
71
|
+
Jettywrapper.is_port_in_use?(TEST_JETTY_PORTS.last).should eql(false)
|
|
72
|
+
end
|
|
66
73
|
end
|
|
67
74
|
|
|
68
75
|
it "raises an error if you try to start a jetty that is already running" do
|
|
69
76
|
jetty_params = {
|
|
70
77
|
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
|
|
71
|
-
:jetty_port =>
|
|
78
|
+
:jetty_port => TEST_JETTY_PORTS.first,
|
|
79
|
+
:startup_wait => 30
|
|
72
80
|
}
|
|
73
81
|
ts = Jettywrapper.configure(jetty_params)
|
|
74
82
|
ts.stop
|
|
75
83
|
ts.pid_file?.should eql(false)
|
|
76
84
|
ts.start
|
|
77
|
-
sleep 30
|
|
78
85
|
lambda{ ts.start }.should raise_exception
|
|
79
86
|
ts.stop
|
|
80
87
|
end
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
|
|
89
|
+
it "raises an error if you try to start a jetty when the port is already in use" do
|
|
90
|
+
jetty_params = {
|
|
91
|
+
:jetty_home => File.expand_path("#{File.dirname(__FILE__)}/../../jetty"),
|
|
92
|
+
:jetty_port => TEST_JETTY_PORTS.first,
|
|
93
|
+
:startup_wait => 30
|
|
94
|
+
}
|
|
95
|
+
socket = TCPServer.new(TEST_JETTY_PORTS.first)
|
|
96
|
+
begin
|
|
97
|
+
ts = Jettywrapper.configure(jetty_params)
|
|
98
|
+
ts.stop
|
|
99
|
+
ts.pid_file?.should eql(false)
|
|
100
|
+
lambda{ ts.start }.should raise_exception
|
|
101
|
+
ts.stop
|
|
102
|
+
ensure
|
|
103
|
+
socket.close
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
83
107
|
end
|
|
84
|
-
|
|
85
108
|
end
|
|
86
109
|
end
|