Skip to content

Commit

Permalink
fix up specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed May 23, 2014
1 parent ff8a321 commit e9c3925
Show file tree
Hide file tree
Showing 24 changed files with 76 additions and 51 deletions.
18 changes: 9 additions & 9 deletions spec/foreman/export/systemd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
it "exports to the filesystem" do
systemd.export

expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/app.target"))
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/app-alpha.target"))
expect(File.read("/tmp/init/app-alpha-1.service")).to eq(example_export_file("systemd/app-alpha-1.service"))
expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/app-bravo.target"))
expect(File.read("/tmp/init/app-bravo-1.service")).to eq(example_export_file("systemd/app-bravo-1.service"))
expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/standard/app.target"))
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/standard/app-alpha.target"))
expect(File.read("/tmp/init/app-alpha-1.service")).to eq(example_export_file("systemd/standard/app-alpha-1.service"))
expect(File.read("/tmp/init/app-bravo.target")).to eq(example_export_file("systemd/standard/app-bravo.target"))
expect(File.read("/tmp/init/app-bravo-1.service")).to eq(example_export_file("systemd/standard/app-bravo-1.service"))
end

it "cleans up if exporting into an existing dir" do
Expand Down Expand Up @@ -50,10 +50,10 @@
it "exports to the filesystem with concurrency" do
systemd.export

expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/app.target"))
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/app-alpha.target"))
expect(File.read("/tmp/init/app-alpha-1.service")).to eq(example_export_file("systemd/app-alpha-1.service"))
expect(File.read("/tmp/init/app-alpha-2.service")).to eq(example_export_file("systemd/app-alpha-2.service"))
expect(File.read("/tmp/init/app.target")).to eq(example_export_file("systemd/concurrency/app.target"))
expect(File.read("/tmp/init/app-alpha.target")).to eq(example_export_file("systemd/concurrency/app-alpha.target"))
expect(File.read("/tmp/init/app-alpha-1.service")).to eq(example_export_file("systemd/concurrency/app-alpha-1.service"))
expect(File.read("/tmp/init/app-alpha-2.service")).to eq(example_export_file("systemd/concurrency/app-alpha-2.service"))
expect(File.exists?("/tmp/init/app-bravo-1.service")).to eq(false)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/foreman/export/upstart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
engine.env['KEY'] = 'd"\|d'
upstart.export
expect("foobarfoo").to include "bar"
expect(File.read("/tmp/init/app-alpha-1.conf")).to match(/KEY=d\\"\\\\\\\|d/)
expect(File.read("/tmp/init/app-alpha-1.conf")).to match(/KEY='d"\\\|d'/)
end

context "with a formation" do
Expand Down
4 changes: 2 additions & 2 deletions spec/resources/export/bluepill/app-concurrency.pill
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil


app.process("alpha-1") do |process|
process.start_command = "./alpha"
process.start_command = %Q{./alpha}

process.working_dir = "/tmp/app"
process.daemonize = true
Expand All @@ -26,7 +26,7 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil


app.process("alpha-2") do |process|
process.start_command = "./alpha"
process.start_command = %Q{./alpha}

process.working_dir = "/tmp/app"
process.daemonize = true
Expand Down
8 changes: 4 additions & 4 deletions spec/resources/export/bluepill/app.pill
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil


app.process("alpha-1") do |process|
process.start_command = "./alpha"
process.start_command = %Q{./alpha}

process.working_dir = "/tmp/app"
process.daemonize = true
Expand All @@ -25,7 +25,7 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil
end

app.process("bravo-1") do |process|
process.start_command = "./bravo"
process.start_command = %Q{./bravo}

process.working_dir = "/tmp/app"
process.daemonize = true
Expand All @@ -43,7 +43,7 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil
end

app.process("foo_bar-1") do |process|
process.start_command = "./foo_bar"
process.start_command = %Q{./foo_bar}

process.working_dir = "/tmp/app"
process.daemonize = true
Expand All @@ -61,7 +61,7 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil
end

app.process("foo-bar-1") do |process|
process.start_command = "./foo-bar"
process.start_command = %Q{./foo-bar}

process.working_dir = "/tmp/app"
process.daemonize = true
Expand Down
1 change: 1 addition & 0 deletions spec/resources/export/runit/app-alpha-1/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
cd /tmp/app
exec 2>&1
exec chpst -u app -e /tmp/init/app-alpha-1/env ./alpha bar=baz
1 change: 1 addition & 0 deletions spec/resources/export/runit/app-alpha-2/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
cd /tmp/app
exec 2>&1
exec chpst -u app -e /tmp/init/app-alpha-2/env ./alpha bar=baz
1 change: 1 addition & 0 deletions spec/resources/export/runit/app-bravo-1/run
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
cd /tmp/app
exec 2>&1
exec chpst -u app -e /tmp/init/app-bravo-1/env ./bravo
5 changes: 0 additions & 5 deletions spec/resources/export/systemd/app-alpha.target

This file was deleted.

5 changes: 0 additions & 5 deletions spec/resources/export/systemd/app-bravo.target

This file was deleted.

1 change: 0 additions & 1 deletion spec/resources/export/systemd/app.target

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
KillMode=process

[Install]
WantedBy=app-alpha.target
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
KillMode=process

[Install]
WantedBy=app-alpha.target
3 changes: 3 additions & 0 deletions spec/resources/export/systemd/concurrency/app-alpha.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Unit]
StopWhenUnneeded=true
Wants=app-alpha-1.service app-alpha-2.service
6 changes: 6 additions & 0 deletions spec/resources/export/systemd/concurrency/app.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
StopWhenUnneeded=true
Wants=app-alpha.target

[Install]
WantedBy=multi-user.target
14 changes: 14 additions & 0 deletions spec/resources/export/systemd/standard/app-alpha-1.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
StopWhenUnneeded=true

[Service]
User=app
WorkingDirectory=/tmp/app
Environment=PORT=5000
ExecStart=/bin/bash -lc './alpha'
Restart=always
StandardInput=null
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
KillMode=process
3 changes: 3 additions & 0 deletions spec/resources/export/systemd/standard/app-alpha.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Unit]
StopWhenUnneeded=true
Wants=app-alpha-1.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,3 @@ StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=%n
KillMode=process

[Install]
WantedBy=app-bravo.target
3 changes: 3 additions & 0 deletions spec/resources/export/systemd/standard/app-bravo.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[Unit]
StopWhenUnneeded=true
Wants=app-bravo-1.service
6 changes: 6 additions & 0 deletions spec/resources/export/systemd/standard/app.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
StopWhenUnneeded=true
Wants=app-alpha.target app-bravo.target app-foo_bar.target app-foo-bar.target

[Install]
WantedBy=multi-user.target
8 changes: 7 additions & 1 deletion spec/resources/export/upstart/app-alpha-1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ start on starting app-alpha
stop on stopping app-alpha
respawn

exec su - app -c 'cd /tmp/app; export PORT=5000; ./alpha >> /var/log/app/alpha-1.log 2>&1'
env PORT=5000

setuid app

chdir /tmp/app

exec ./alpha
8 changes: 7 additions & 1 deletion spec/resources/export/upstart/app-alpha-2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ start on starting app-alpha
stop on stopping app-alpha
respawn

exec su - app -c 'cd /tmp/app; export PORT=5001; ./alpha >> /var/log/app/alpha-2.log 2>&1'
env PORT=5001

setuid app

chdir /tmp/app

exec ./alpha
8 changes: 7 additions & 1 deletion spec/resources/export/upstart/app-bravo-1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ start on starting app-bravo
stop on stopping app-bravo
respawn

exec su - app -c 'cd /tmp/app; export PORT=5100; ./bravo >> /var/log/app/bravo-1.log 2>&1'
env PORT=5100

setuid app

chdir /tmp/app

exec ./bravo
12 changes: 1 addition & 11 deletions spec/resources/export/upstart/app.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
pre-start script

bash << "EOF"
mkdir -p /var/log/app
chown -R app /var/log/app
EOF

end script

start on runlevel [2345]

stop on runlevel [016]
stop on runlevel [!2345]
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,4 @@ def capture_stdout
config.order = 'rand'
config.include FakeFS::SpecHelpers, :fakefs
config.mock_with :rr
config.backtrace_clean_patterns = []
end

0 comments on commit e9c3925

Please sign in to comment.