hydra-head 3.1.0.pre4 → 3.1.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
data/lib/hydra-head/version.rb
CHANGED
data/lib/hydra.rb
CHANGED
@@ -18,8 +18,8 @@ namespace :hydra do
|
|
18
18
|
desc "Copies the contents of solr_conf into the Solr development-core and test-core of Testing Server"
|
19
19
|
task :config_solr do
|
20
20
|
FileList['solr_conf/conf/*'].each do |f|
|
21
|
-
cp("#{f}", 'jetty/solr/development-core/
|
22
|
-
cp("#{f}", 'jetty/solr/test-core/
|
21
|
+
cp("#{f}", 'jetty/solr/development-core/conf/', :verbose => true)
|
22
|
+
cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-head
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1923832019
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 3.1.0.
|
11
|
+
- 5
|
12
|
+
version: 3.1.0.pre5
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield, Justin Coyne & many more. See https://github.com/projecthydra/hydra-head/contributors
|
@@ -984,7 +984,6 @@ files:
|
|
984
984
|
- lib/hydra/rights_metadata.rb
|
985
985
|
- lib/hydra/submission_workflow.rb
|
986
986
|
- lib/hydra/superuser_attributes.rb
|
987
|
-
- lib/hydra/testing_server.rb
|
988
987
|
- lib/hydra/user.rb
|
989
988
|
- lib/jetty_cleaner.rb
|
990
989
|
- lib/marc_mapper.rb
|
@@ -1127,7 +1126,6 @@ files:
|
|
1127
1126
|
- test_support/spec/support/matchers/solr_matchers.rb
|
1128
1127
|
- test_support/spec/unit/hydra-head-engine_spec.rb
|
1129
1128
|
- test_support/spec/unit/hydra-head_spec.rb
|
1130
|
-
- test_support/spec/utilities/hydra_testing_server_spec.rb
|
1131
1129
|
- test_support/spec/views/uploader.html.erb_spec.rb
|
1132
1130
|
- tmp/.placeholder
|
1133
1131
|
- uninstall.rb
|
data/lib/hydra/testing_server.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
# The ASF licenses this file to You under the Apache License, Version 2.0
|
2
|
-
# (the "License"); you may not use this file except in compliance with
|
3
|
-
# the License. You may obtain a copy of the License at
|
4
|
-
#
|
5
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
-
#
|
7
|
-
# Unless required by applicable law or agreed to in writing, software
|
8
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
-
# See the License for the specific language governing permissions and
|
11
|
-
# limitations under the License.
|
12
|
-
|
13
|
-
|
14
|
-
module Hydra
|
15
|
-
# A singleton class for starting/stopping a Jetty server for testing purposes
|
16
|
-
# The behavior of TestSolrServer can be modified prior to start() by changing
|
17
|
-
# port, solr_home, and quiet properties.
|
18
|
-
#
|
19
|
-
# This class is based on Blacklight's TestSolrServer
|
20
|
-
class TestingServer
|
21
|
-
require 'singleton'
|
22
|
-
include Singleton
|
23
|
-
require 'win32/process' if RUBY_PLATFORM =~ /mswin32/
|
24
|
-
attr_accessor :port, :jetty_home, :solr_home, :quiet, :fedora_home, :base_path
|
25
|
-
|
26
|
-
# configure the singleton with some defaults
|
27
|
-
def initialize(params = {})
|
28
|
-
@pid = nil
|
29
|
-
if defined?(Rails.root)
|
30
|
-
@base_path = Rails.root
|
31
|
-
else
|
32
|
-
@base_path = "."
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class << self
|
37
|
-
def configure(params = {})
|
38
|
-
hydra_server = self.instance
|
39
|
-
hydra_server.quiet = params[:quiet].nil? ? true : params[:quiet]
|
40
|
-
if defined?(Rails.root)
|
41
|
-
base_path = Rails.root
|
42
|
-
else
|
43
|
-
base_path = "."
|
44
|
-
end
|
45
|
-
hydra_server.jetty_home = params[:jetty_home] || File.expand_path(File.join(base_path, 'jetty'))
|
46
|
-
hydra_server.solr_home = params[:solr_home] || File.join( hydra_server.jetty_home, "solr")
|
47
|
-
hydra_server.fedora_home = params[:fedora_home] || File.join( hydra_server.jetty_home, "fedora","default")
|
48
|
-
hydra_server.port = params[:jetty_port] || 8888
|
49
|
-
return hydra_server
|
50
|
-
end
|
51
|
-
|
52
|
-
def wrap(params = {})
|
53
|
-
error = false
|
54
|
-
hydra_server = self.configure(params)
|
55
|
-
begin
|
56
|
-
puts "starting Hydra jetty server on #{RUBY_PLATFORM}"
|
57
|
-
hydra_server.start
|
58
|
-
sleep params[:startup_wait] || 5
|
59
|
-
yield
|
60
|
-
rescue
|
61
|
-
error = true
|
62
|
-
ensure
|
63
|
-
puts "stopping Hydra jetty server"
|
64
|
-
hydra_server.stop
|
65
|
-
end
|
66
|
-
|
67
|
-
return error
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def jetty_command
|
72
|
-
"java -Djetty.port=#{@port} -Dsolr.solr.home=#{@solr_home} -Dfedora.home=#{@fedora_home} -jar start.jar"
|
73
|
-
end
|
74
|
-
|
75
|
-
def start
|
76
|
-
puts "jetty_home: #{@jetty_home}"
|
77
|
-
puts "solr_home: #{@solr_home}"
|
78
|
-
puts "fedora_home: #{@fedora_home}"
|
79
|
-
puts "jetty_command: #{jetty_command}"
|
80
|
-
if pid
|
81
|
-
begin
|
82
|
-
Process.kill(0,pid)
|
83
|
-
raise("Server is already running with PID #{pid}")
|
84
|
-
rescue Errno::ESRCH
|
85
|
-
STDERR.puts("Removing stale PID file at #{pid_path}")
|
86
|
-
File.delete(pid_path)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
Dir.chdir(@jetty_home) do
|
90
|
-
self.send "#{platform}_process".to_sym
|
91
|
-
end
|
92
|
-
mkpath(pid_dir) unless File.directory?(pid_dir)
|
93
|
-
begin
|
94
|
-
f = File.new(pid_path, "w")
|
95
|
-
rescue Errno::ENOENT, Errno::EACCES
|
96
|
-
f = File.new(File.join(@base_path,'tmp',pid_file),"w")
|
97
|
-
end
|
98
|
-
f.puts "#{@pid}"
|
99
|
-
f.close
|
100
|
-
end
|
101
|
-
|
102
|
-
def stop
|
103
|
-
puts "stopping"
|
104
|
-
if pid
|
105
|
-
begin
|
106
|
-
self.send "#{platform}_stop".to_sym
|
107
|
-
rescue Errno::ESRCH
|
108
|
-
STDERR.puts("Removing stale PID file at #{pid_path}")
|
109
|
-
end
|
110
|
-
FileUtils.rm(pid_path)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def win_process
|
115
|
-
@pid = Process.create(
|
116
|
-
:app_name => jetty_command,
|
117
|
-
:creation_flags => Process::DETACHED_PROCESS,
|
118
|
-
:process_inherit => false,
|
119
|
-
:thread_inherit => true,
|
120
|
-
:cwd => "#{@jetty_home}"
|
121
|
-
).process_id
|
122
|
-
end
|
123
|
-
|
124
|
-
def platform
|
125
|
-
case RUBY_PLATFORM
|
126
|
-
when /mswin32/
|
127
|
-
return 'win'
|
128
|
-
else
|
129
|
-
return 'nix'
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
def nix_process
|
134
|
-
@pid = fork do
|
135
|
-
STDERR.close if @quiet
|
136
|
-
exec jetty_command
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
# stop a running solr server
|
141
|
-
def win_stop
|
142
|
-
Process.kill(1, @pid)
|
143
|
-
end
|
144
|
-
|
145
|
-
def nix_stop
|
146
|
-
Process.kill('TERM',pid)
|
147
|
-
end
|
148
|
-
|
149
|
-
def pid_path
|
150
|
-
File.join(pid_dir, pid_file)
|
151
|
-
end
|
152
|
-
|
153
|
-
def pid_file
|
154
|
-
@pid_file || 'hydra-jetty.pid'
|
155
|
-
end
|
156
|
-
|
157
|
-
def pid_dir
|
158
|
-
File.expand_path(@pid_dir || File.join(@base_path,'tmp','pids'))
|
159
|
-
end
|
160
|
-
|
161
|
-
def pid
|
162
|
-
@pid || File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
|
163
|
-
end
|
164
|
-
|
165
|
-
end # class TestingServer
|
166
|
-
end # module Hydra
|
167
|
-
|
168
|
-
#
|
169
|
-
# puts "hello"
|
170
|
-
# SOLR_PARAMS = {
|
171
|
-
# :quiet => ENV['SOLR_CONSOLE'] ? false : true,
|
172
|
-
# :jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('../../jetty'),
|
173
|
-
# :jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
|
174
|
-
# :solr_home => ENV['SOLR_HOME'] || File.expand_path('test')
|
175
|
-
# }
|
176
|
-
#
|
177
|
-
# # wrap functional tests with a test-specific Solr server
|
178
|
-
# got_error = TestSolrServer.wrap(SOLR_PARAMS) do
|
179
|
-
# puts `ps aux | grep start.jar`
|
180
|
-
# end
|
181
|
-
#
|
182
|
-
# raise "test failures" if got_error
|
183
|
-
#
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
# require File.expand_path(File.dirname(__FILE__) + '/../../lib/hydra/hydra_testing_server.rb')
|
3
|
-
|
4
|
-
describe Hydra::TestingServer do
|
5
|
-
|
6
|
-
it "should be configurable with params hash" do
|
7
|
-
jetty_params = {
|
8
|
-
:quiet => false,
|
9
|
-
:jetty_home => "/path/to/jetty",
|
10
|
-
:jetty_port => 8888,
|
11
|
-
:solr_home => '/path/to/solr',
|
12
|
-
:fedora_home => '/path/to/fedora'
|
13
|
-
}
|
14
|
-
|
15
|
-
ts = Hydra::TestingServer.configure(jetty_params)
|
16
|
-
ts.quiet.should == false
|
17
|
-
ts.jetty_home.should == "/path/to/jetty"
|
18
|
-
ts.port.should == 8888
|
19
|
-
ts.solr_home.should == '/path/to/solr'
|
20
|
-
ts.fedora_home.should == '/path/to/fedora'
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should be configurable with default values" do
|
24
|
-
ts = Hydra::TestingServer.configure
|
25
|
-
ts.quiet.should == true
|
26
|
-
ts.jetty_home.should == File.join(::Rails.root.to_s, "jetty")
|
27
|
-
ts.port.should == 8888
|
28
|
-
ts.solr_home.should == File.join(ts.jetty_home, "solr" )
|
29
|
-
ts.fedora_home.should == File.join(ts.jetty_home, "fedora","default")
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should override nil params with defaults" do
|
33
|
-
jetty_params = {
|
34
|
-
:quiet => false,
|
35
|
-
:jetty_home => nil,
|
36
|
-
:jetty_port => 8888,
|
37
|
-
:solr_home => '/path/to/solr',
|
38
|
-
:fedora_home => nil
|
39
|
-
}
|
40
|
-
|
41
|
-
ts = Hydra::TestingServer.configure(jetty_params)
|
42
|
-
ts.quiet.should == false
|
43
|
-
ts.jetty_home.should == File.join(::Rails.root.to_s, "jetty")
|
44
|
-
ts.port.should == 8888
|
45
|
-
ts.solr_home.should == "/path/to/solr"
|
46
|
-
ts.fedora_home.should == File.join(ts.jetty_home, "fedora","default")
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|