~ubuntu-branches/ubuntu/wily/ruby-passenger/wily-proposed

« back to all changes in this revision

Viewing changes to test/integration_tests/native_packaging_spec.rb

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-11-23 23:50:02 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131123235002-8fdhsq7afj15o2z2
Tags: 4.0.25-1
* New upstream release.
* Refresh fix_install_path.patch.
* Build for Ruby 2.0 instead of 1.8. (Closes: #725591)
* Add fix_ftbfs_fortify_source.patch.
* Install passenger template files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
23
#  THE SOFTWARE.
24
24
 
 
25
# To run the native packaging tests:
 
26
#     rake debian:dev debian:dev:reinstall
 
27
#     rvmsudo env LOCATIONS_INI=/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini \
 
28
#         rspec -f s -c test/integration_tests/native_packaging_spec.rb
 
29
 
25
30
# Ensure that the natively installed tools are in PATH.
26
31
ENV['PATH'] = "/usr/bin:#{ENV['PATH']}"
27
32
LOCATIONS_INI = ENV['LOCATIONS_INI']
28
33
abort "Please set the LOCATIONS_INI environment variable to the right locations.ini" if !LOCATIONS_INI
29
34
 
 
35
source_root = File.expand_path("../..", File.dirname(__FILE__))
 
36
$LOAD_PATH.unshift("#{source_root}/lib")
 
37
require 'phusion_passenger'
 
38
require 'tmpdir'
 
39
require 'fileutils'
 
40
require 'open-uri'
 
41
 
30
42
BINDIR = "/usr/bin"
31
43
SBINDIR = "/usr/sbin"
32
 
INCLUDEDIR = "/usr/share/passenger/include"
33
 
NGINX_ADDON_DIR = "/usr/share/passenger/ngx_http_passenger_module"
34
 
DOCDIR = "/usr/share/doc/ruby-passenger"
35
 
RESOURCESDIR = "/usr/share/passenger"
36
 
RUBY_EXTENSION_SOURCE_DIR = "/usr/share/passenger/ruby_extension_source"
37
 
AGENTS_DIR = "/usr/lib/passenger/agents"
 
44
INCLUDEDIR = "/usr/share/#{PhusionPassenger::GLOBAL_NAMESPACE_DIRNAME}/include"
 
45
NGINX_ADDON_DIR = "/usr/share/#{PhusionPassenger::GLOBAL_NAMESPACE_DIRNAME}/ngx_http_passenger_module"
 
46
DOCDIR = "/usr/share/doc/passenger"
 
47
RESOURCESDIR = "/usr/share/#{PhusionPassenger::GLOBAL_NAMESPACE_DIRNAME}"
 
48
RUBY_EXTENSION_SOURCE_DIR = "/usr/share/#{PhusionPassenger::GLOBAL_NAMESPACE_DIRNAME}/ruby_extension_source"
 
49
AGENTS_DIR = "/usr/lib/#{PhusionPassenger::GLOBAL_NAMESPACE_DIRNAME}/agents"
38
50
APACHE2_MODULE_PATH = "/usr/lib/apache2/modules/mod_passenger.so"
39
51
 
40
52
describe "A natively packaged Phusion Passenger" do
43
55
                if $?.exitstatus == 0
44
56
                        return output
45
57
                else
46
 
                        abort "Command #{command.join(' ')} exited with status #{$?.exitstatus}"
 
58
                        abort "Command #{command} exited with status #{$?.exitstatus}"
47
59
                end
48
60
        end
49
61
 
51
63
                return capture_output("which #{command}")
52
64
        end
53
65
 
 
66
        def sh(*command)
 
67
                if !system(*command)
 
68
                        abort "Command failed: #{command.join(' ')}"
 
69
                end
 
70
        end
 
71
 
54
72
        specify "locations.ini only refers to existent filesystem locations" do
55
73
                File.read(LOCATIONS_INI).split("\n").each do |line|
56
74
                        if line =~ /=/
62
80
                end
63
81
        end
64
82
 
65
 
        specify "passenger-install-nginx-module is in #{BINDIR}" do
66
 
                which("passenger-install-nginx-module").should == "#{BINDIR}/passenger-install-nginx-module"
67
 
        end
68
 
 
69
83
        specify "passenger-status is in #{SBINDIR}" do
70
84
                which("passenger-status").should == "#{SBINDIR}/passenger-status"
71
85
        end
122
136
                        system("passenger-config --natively-packaged").should be_true
123
137
                end
124
138
 
 
139
                it "recognizes the install as coming from an official package" do
 
140
                        system("passenger-config --installed-from-release-package").should be_true
 
141
                end
 
142
 
 
143
                it "recognizes the system's Apache" do
 
144
                        output = capture_output("passenger-config --detect-apache2")
 
145
                        output.gsub!(/.*Final autodetection results\n/m, '')
 
146
                        output.scan(/\* Found Apache .*\!/).size.should == 1
 
147
                        output.should include("apxs2          : /usr/bin/apxs2\n")
 
148
                        output.should include("Main executable: /usr/sbin/apache2\n")
 
149
                        output.should include("Control command: /usr/sbin/apache2ctl\n")
 
150
                        output.should include("Config file    : /etc/apache2/apache2.conf\n")
 
151
                        output.should include("Error log file : /var/log/apache2/error.log\n")
 
152
                        output.should include(%Q{
 
153
   To start, stop or restart this specific Apache version:
 
154
      /usr/sbin/apache2ctl start
 
155
      /usr/sbin/apache2ctl stop
 
156
      /usr/sbin/apache2ctl restart})
 
157
                        output.should include(%Q{
 
158
   To troubleshoot, please read the logs in this file:
 
159
      /var/log/apache2/error.log})
 
160
                end
 
161
 
125
162
                it "shows the directory to the runtime library headers" do
126
163
                        capture_output("passenger-config --includedir").should == INCLUDEDIR
127
164
                end
167
204
                        output.should include("PassengerRoot #{LOCATIONS_INI}")
168
205
                end
169
206
        end
 
207
 
 
208
        describe "passenger-install-nginx-module" do
 
209
                it "is in #{BINDIR}" do
 
210
                        which("passenger-install-nginx-module").should == "#{BINDIR}/passenger-install-nginx-module"
 
211
                end
 
212
 
 
213
                it "is able to compile Nginx" do
 
214
                        Dir.mktmpdir do |path|
 
215
                                output = capture_output("passenger-install-nginx-module --auto --prefix=#{path} --auto-download 2>&1")
 
216
                                output.should include("passenger_root #{LOCATIONS_INI};")
 
217
                                File.exist?("#{path}/sbin/nginx").should be_true
 
218
                        end
 
219
                end
 
220
        end
 
221
 
 
222
        describe "Passenger Standalone" do
 
223
                it "is in #{BINDIR}" do
 
224
                        which("passenger").should == "#{BINDIR}/passenger"
 
225
                end
 
226
 
 
227
                it "works" do
 
228
                        Dir.mktmpdir do |dir|
 
229
                                File.chmod(0755, dir)
 
230
                                Dir.chdir(dir) do
 
231
                                        File.open("config.ru", "w") do |f|
 
232
                                                f.write(%Q{
 
233
                                                        app = lambda do |env|
 
234
                                                                [200, { "Content-Type" => "text/plain" }, ["ok"]]
 
235
                                                        end
 
236
                                                        run app
 
237
                                                })
 
238
                                        end
 
239
                                        Dir.mkdir("public")
 
240
                                        Dir.mkdir("tmp")
 
241
                                        sh("passenger start --no-compile-runtime -p 4000 -d >/dev/null")
 
242
                                        begin
 
243
                                                open("http://127.0.0.1:4000/") do |f|
 
244
                                                        f.read.should == "ok"
 
245
                                                end
 
246
                                        ensure
 
247
                                                sh("passenger stop -p 4000")
 
248
                                        end
 
249
                                end
 
250
                        end
 
251
                end
 
252
        end
170
253
end