This repository has been archived by the owner on Feb 7, 2020. It is now read-only.
/
web_spec.rb
67 lines (54 loc) · 2.52 KB
/
web_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require "spec_helper"
require "yaml"
describe "jetpack - web start" do
let(:project) { "#{TEST_ROOT}/webapp" }
let(:dest) { "#{TEST_ROOT}/webapp_dest" }
before(:all) do
reset
FileUtils.cp_r("spec/sample_projects/webapp", "#{TEST_ROOT}/")
x!("bin/jetpack-bootstrap #{project} http")
@result = x!("bin/jetpack #{project} #{dest}")
end
after(:all) do
reset
end
describe "http bootstrap" do
it "places jetty config files" do
File.exists?("#{project}/config/jetpack_files/WEB-INF/web.xml.erb").should == true
File.exists?("#{project}/config/jetpack_files/vendor/jetty/etc/jetty.xml.erb").should == true
end
it "places a launch script, and includes java_options" do
File.exists?("#{project}/config/jetpack_files/bin/launch.erb").should == true
end
end
it "will unzip jetty under vendor if jetty.xml is present" do
@result[:stderr].should == ""
@result[:exitstatus].should == 0
File.directory?("#{dest}/vendor/jetty").should == true
File.directory?("#{dest}/vendor/jetty/lib").should == true
File.exists?("#{dest}/vendor/jetty/start.jar").should == true
end
it "respects the maximun number of concurrent connections, http and https port" do
jetty_xml = "#{dest}/vendor/jetty/etc/jetty.xml"
settings = YAML.load_file("#{dest}/config/jetpack.yml")
max_threads_setting = /<Set name="maxThreads">#{settings["max_concurrent_connections"]}<\/Set>/
File.exists?(jetty_xml).should == true
jetty_xml_content = File.readlines(jetty_xml)
jetty_xml_content.grep(max_threads_setting).should_not be_empty
jetty_xml_content.grep(/<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">/).should_not be_empty
jetty_xml_content.grep(/<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">/).should_not be_empty
end
it "runs" do
pid_to_kill = run_app(dest, check_port=9080)
begin
#HTTP XX443 - intended to be proxied to from something listening on 443
x!("curl https://localhost:9443/hello --insecure")[:stdout].split("<br/>").first.strip.should == "Hello World"
#HTTP XXX80 - intended for internal health checking
x!("curl http://localhost:9080/hello")[:stdout].split("<br/>").first.strip.should == "Hello World"
x!("curl http://#{Socket.gethostname}:9080/hello")[:stdout].split("<br/>").first.strip.should == "Hello World"
x!("curl http://127.0.0.1:9080/hello")[:stdout].split("<br/>").first.strip.should == "Hello World"
ensure
system("kill -9 #{pid_to_kill}")
end
end
end