gorgon 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gorgon (0.6.1)
5
- amqp (~> 0.9.7)
4
+ gorgon (0.6.2)
5
+ amqp (~> 1.1.0)
6
6
  awesome_print
7
7
  colorize (~> 0.5.8)
8
8
  open4 (~> 1.3.0)
@@ -13,13 +13,9 @@ PATH
13
13
  GEM
14
14
  remote: http://rubygems.org/
15
15
  specs:
16
- amq-client (0.9.12)
17
- amq-protocol (>= 1.2.0)
18
- eventmachine
19
- amq-protocol (1.2.0)
20
- amqp (0.9.10)
21
- amq-client (~> 0.9.12)
22
- amq-protocol (~> 1.2.0)
16
+ amq-protocol (1.8.0)
17
+ amqp (1.1.0)
18
+ amq-protocol (>= 1.8.0)
23
19
  eventmachine
24
20
  awesome_print (1.2.0)
25
21
  colorize (0.5.8)
data/gorgon.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "test-unit"
23
23
  s.add_development_dependency "rspec", '~>2.11.0'
24
24
 
25
- s.add_runtime_dependency "amqp", '~>0.9.7'
25
+ s.add_runtime_dependency "amqp", '~> 1.1.0'
26
26
  s.add_runtime_dependency "awesome_print"
27
27
  s.add_runtime_dependency "open4", '~>1.3.0'
28
28
  s.add_runtime_dependency "ruby-progressbar", '~>1.0.1'
@@ -25,7 +25,7 @@ class Originator
25
25
 
26
26
  publish
27
27
  @logger.log "Originator finished successfully"
28
- rescue Exception
28
+ rescue StandardError
29
29
  puts "Unhandled exception in originator:"
30
30
  puts $!.message
31
31
  puts $!.backtrace.join("\n")
@@ -51,8 +51,18 @@ class Originator
51
51
 
52
52
  def publish
53
53
  @logger = OriginatorLogger.new configuration[:originator_log_file]
54
+
55
+ if files.empty?
56
+ $stderr.puts "There are no files to test! Quitting."
57
+ exit 2
58
+ end
59
+
60
+ if !@rsync_daemon.start
61
+ @logger.log_error "rsync daemon didn't start!"
62
+ exit 1
63
+ end
64
+
54
65
  @protocol = OriginatorProtocol.new @logger
55
- @rsync_daemon.start
56
66
 
57
67
  EventMachine.run do
58
68
  @logger.log "Connecting..."
@@ -97,7 +97,7 @@ private
97
97
  @job_state.each_failed_test do |test|
98
98
  puts "\n" + ('*' * 80).magenta #light_red
99
99
  puts("File '#{test[:filename].colorize(Colors::FILENAME)}' failed/crashed at " \
100
- + "'#{test[:hostname].colorize(Colors::HOST)}'\n")
100
+ + "'#{test[:hostname].colorize(Colors::HOST)}:#{test[:worker_id]}'\n")
101
101
  msg = build_fail_message test[:failures]
102
102
  puts "#{msg}\n"
103
103
  end
@@ -137,10 +137,7 @@ private
137
137
  result = "#{'Test name'.light_yellow}: #{failure[:test_name]}"
138
138
  result << "\n#{failure[:class].red}" if failure[:class]
139
139
  result << "\n#{'Message:'.light_yellow} \n\t#{failure[:message]}" if failure[:message]
140
- if failure[:location]
141
- result << "\n#{'In:'.light_yellow} \n\t"
142
- result << failure[:location].join("\n\t")
143
- end
140
+ result << "\n"
144
141
  result
145
142
  end
146
143
  end
@@ -2,6 +2,9 @@ require "tmpdir"
2
2
 
3
3
  class RsyncDaemon
4
4
  #for now, creates a readonly rsync daemon for the current directory on the mountpath "src"
5
+ RSYNC_DIR_NAME = "#{Dir.tmpdir}/gorgon_rsync_daemon"
6
+ RSYNC_PORT = 43434
7
+ PID_FILE = 'rsync.pid'
5
8
 
6
9
  def initialize
7
10
  @project_directory = Dir.pwd
@@ -10,9 +13,15 @@ class RsyncDaemon
10
13
 
11
14
  def start
12
15
  return if @started
13
- @tmpdir = Dir.mktmpdir("gorgon")
16
+
17
+ if !port_available?
18
+ puts port_busy_msg
19
+ return false
20
+ end
21
+
22
+ Dir.mkdir(RSYNC_DIR_NAME)
14
23
  success = nil
15
- Dir.chdir(@tmpdir) do
24
+ Dir.chdir(RSYNC_DIR_NAME) do
16
25
  File.write("rsyncd.conf", rsyncd_config_string(@project_directory))
17
26
 
18
27
  success = Kernel.system("rsync --daemon --config rsyncd.conf")
@@ -30,13 +39,14 @@ class RsyncDaemon
30
39
  return unless @started
31
40
 
32
41
  success = nil
33
- Dir.chdir(@tmpdir) do
34
- pid = File.read("rsync.pid")
42
+ Dir.chdir(RSYNC_DIR_NAME) do
43
+ pid = File.read(PID_FILE)
35
44
  success = Kernel.system("kill #{pid}")
36
45
  end
37
46
 
38
47
  if success
39
48
  @started = false
49
+ FileUtils::remove_entry_secure(RSYNC_DIR_NAME)
40
50
  return true
41
51
  else
42
52
  return false
@@ -47,8 +57,8 @@ class RsyncDaemon
47
57
 
48
58
  def rsyncd_config_string(shared_dir)
49
59
  return <<-EOF
50
- port = 43434
51
- pid file = rsync.pid
60
+ port = #{RSYNC_PORT}
61
+ pid file = #{PID_FILE}
52
62
 
53
63
  [src]
54
64
  path = #{@project_directory}
@@ -56,4 +66,21 @@ pid file = rsync.pid
56
66
  use chroot = false
57
67
  EOF
58
68
  end
59
- end
69
+
70
+ def port_available?
71
+ begin
72
+ s = TCPServer.new('localhost', RSYNC_PORT)
73
+ s.close
74
+ return true
75
+ rescue Errno::EADDRINUSE => _
76
+ return false
77
+ end
78
+ end
79
+
80
+ def port_busy_msg
81
+ <<-MSG
82
+ ERROR: port #{RSYNC_PORT} is being used. Maybe another rsync daemon is running.
83
+ Kill pid in #{RSYNC_DIR_NAME}/#{PID_FILE} or check no other process is using that port."
84
+ MSG
85
+ end
86
+ end
@@ -1,3 +1,3 @@
1
1
  module Gorgon
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -15,6 +15,7 @@ describe Originator do
15
15
  before do
16
16
  OriginatorLogger.stub(:new).and_return originator_logger
17
17
  RsyncDaemon.stub(:new).and_return rsync_daemon
18
+ Dir.stub(:[]).and_return(["file"])
18
19
  @originator = Originator.new
19
20
  end
20
21
 
@@ -42,6 +43,16 @@ describe Originator do
42
43
 
43
44
  @originator.publish
44
45
  end
46
+
47
+ it "errors and halts when there are no test files" do
48
+ Dir.stub(:[] => [])
49
+
50
+ $stderr.should_receive(:puts)
51
+ OriginatorProtocol.should_not_receive(:new)
52
+ rsync_daemon.should_not_receive(:start)
53
+
54
+ expect { @originator.publish }.to raise_error(SystemExit)
55
+ end
45
56
  end
46
57
 
47
58
  describe "#cancel_job" do
@@ -3,9 +3,10 @@ require 'gorgon/rsync_daemon'
3
3
  describe RsyncDaemon do
4
4
  before(:each) do
5
5
  Kernel.stub(:system => true)
6
- Dir.stub(:mktmpdir => "loltmpdir", :pwd => "/lol/hax")
6
+ Dir.stub(:mkdir => nil, :pwd => "/lol/hax")
7
7
  Dir.stub(:chdir).and_yield
8
8
  File.stub(:write => 100, :read => "12345")
9
+ FileUtils.stub(:remove_entry_secure => nil)
9
10
  @r = RsyncDaemon.new
10
11
  end
11
12
 
@@ -15,9 +16,9 @@ describe RsyncDaemon do
15
16
  @r.start
16
17
  end
17
18
 
18
- it "creates a temporary directory for the configuration and pid files" do
19
- Dir.should_receive(:mktmpdir).with("gorgon").and_return("loltmpdir")
20
- Dir.should_receive(:chdir).with("loltmpdir")
19
+ it "creates a directory in temporary dir for the configuration and pid files" do
20
+ Dir.should_receive(:mkdir).with(RsyncDaemon::RSYNC_DIR_NAME)
21
+ Dir.should_receive(:chdir).with(RsyncDaemon::RSYNC_DIR_NAME)
21
22
 
22
23
  @r.start
23
24
  end
@@ -72,4 +73,4 @@ EOF
72
73
  @r.stop
73
74
  @r.start
74
75
  end
75
- end
76
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorgon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-10-31 00:00:00.000000000 Z
16
+ date: 2013-11-01 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
@@ -70,7 +70,7 @@ dependencies:
70
70
  requirements:
71
71
  - - ~>
72
72
  - !ruby/object:Gem::Version
73
- version: 0.9.7
73
+ version: 1.1.0
74
74
  type: :runtime
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
@@ -78,7 +78,7 @@ dependencies:
78
78
  requirements:
79
79
  - - ~>
80
80
  - !ruby/object:Gem::Version
81
- version: 0.9.7
81
+ version: 1.1.0
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: awesome_print
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -324,7 +324,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
324
324
  version: '0'
325
325
  segments:
326
326
  - 0
327
- hash: 337737538623619091
327
+ hash: 3410208500792599810
328
328
  required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  none: false
330
330
  requirements:
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  segments:
335
335
  - 0
336
- hash: 337737538623619091
336
+ hash: 3410208500792599810
337
337
  requirements: []
338
338
  rubyforge_project: gorgon
339
339
  rubygems_version: 1.8.25