right_chimp 2.1.28 → 2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +4 -0
  3. data/Gemfile.lock +16 -11
  4. data/chimp.gemspec +1 -1
  5. data/lib/right_chimp/Chimp.rb +5 -5
  6. data/lib/right_chimp/daemon/{ChimpDaemon.rb → chimp_daemon.rb} +6 -7
  7. data/lib/right_chimp/daemon/{ChimpDaemonClient.rb → chimp_daemon_client.rb} +0 -0
  8. data/lib/right_chimp/exec/{ExecArray.rb → exec_array.rb} +5 -7
  9. data/lib/right_chimp/exec/{ExecCallback.rb → exec_callback.rb} +1 -1
  10. data/lib/right_chimp/exec/{ExecNoop.rb → exec_noop.rb} +0 -0
  11. data/lib/right_chimp/exec/{ExecReport.rb → exec_report.rb} +0 -0
  12. data/lib/right_chimp/exec/{ExecRightScript.rb → exec_rightscript.rb} +2 -3
  13. data/lib/right_chimp/exec/{ExecSSH.rb → exec_ssh.rb} +0 -0
  14. data/lib/right_chimp/{IDManager.rb → id_manager.rb} +0 -0
  15. data/lib/right_chimp/queue/{ChimpQueue.rb → chimp_queue.rb} +0 -0
  16. data/lib/right_chimp/queue/{ExecutionGroup.rb → execution_group.rb} +0 -0
  17. data/lib/right_chimp/queue/{QueueWorker.rb → queue_worker.rb} +0 -0
  18. data/lib/right_chimp/resources/Executable.rb +16 -15
  19. data/lib/right_chimp/version.rb +1 -1
  20. data/lib/right_chimp.rb +23 -22
  21. data/spec/chimp_daemon_client_spec.rb +82 -0
  22. data/spec/chimp_daemon_spec.rb +55 -0
  23. data/spec/exec_righscript_spec.rb +41 -0
  24. data/spec/spec_helper.rb +7 -0
  25. metadata +26 -34
  26. data/spec/spec_chimp.rb +0 -20
  27. data/spec/spec_chimp_commandline.rb +0 -55
  28. data/spec/spec_chimpd.rb +0 -33
  29. data/spec/spec_chimpd_client.rb +0 -44
  30. data/spec/spec_execution_group.rb +0 -135
  31. data/spec/spec_queue.rb +0 -37
  32. data/spec/spec_queue_worker.rb +0 -30
  33. data/spec/spec_selection.rb +0 -33
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4500754260b1df0b21af07eed9bd20591e227d3
4
- data.tar.gz: ae09d843fb8c1323b04662ea20b46ab5aee756fc
3
+ metadata.gz: deb10edd310b0e400ce12bafcc0592b52928cdb6
4
+ data.tar.gz: d9a8ede4dfd0778475dbfcc26a38cacf55ada64b
5
5
  SHA512:
6
- metadata.gz: 3912f54d07ee75639188a9280400f64ed7810404972978e0db0af023943631d76133abbba2d78db20e229f9e5fef48e66606b98477b66f81c4401df27d3be48c
7
- data.tar.gz: 6e7c5de7246ce757b170933c986d4c1500a515918af04dd5a56a07d377a21d68a82112170bebd9d5cecaa7515b430c1e4dd310aa2cc0c1bb64c4c4b0cb2ce0e7
6
+ metadata.gz: 8d74afffc79fc7acc94041edd181e8b8f2f2cc60b7747e00004d6814b0edb556d0acd01c6613457c2efc917eccac03107171b3a0bbb7d721b33d9862784193ff
7
+ data.tar.gz: 1c2d8eeb42cb8e14245d767500cbd4dbff06b88e3a84e798ec84a3861d97639375fa6e08e838ac6086169f1a049601f3d6a1508aad014a9dade01e31be41e829
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ Version 2.2
2
+ --------------
3
+ * Feature: Starting to add proper specs that do not rely on actual-real executions.
4
+
1
5
  Version 2.1.28
2
6
  --------------
3
7
  * Bugfix: Do not attempt to decrease the processing counter when handling a retry.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- right_chimp (2.1.28)
4
+ right_chimp (2.2)
5
5
  highline (~> 1.7.2)
6
6
  nokogiri (~> 1.6.7.1)
7
7
  progressbar (~> 0.11.0)
@@ -15,7 +15,7 @@ GEM
15
15
  debug_inspector (>= 0.0.1)
16
16
  coderay (1.1.1)
17
17
  debug_inspector (0.0.2)
18
- diff-lcs (1.1.3)
18
+ diff-lcs (1.2.5)
19
19
  domain_name (0.5.20160826)
20
20
  unf (>= 0.0.5, < 1.0.0)
21
21
  highline (1.7.8)
@@ -45,14 +45,19 @@ GEM
45
45
  json (~> 1.0)
46
46
  mime-types (~> 1.0)
47
47
  rest-client (~> 1.6)
48
- rspec (2.6.0)
49
- rspec-core (~> 2.6.0)
50
- rspec-expectations (~> 2.6.0)
51
- rspec-mocks (~> 2.6.0)
52
- rspec-core (2.6.4)
53
- rspec-expectations (2.6.0)
54
- diff-lcs (~> 1.1.2)
55
- rspec-mocks (2.6.0)
48
+ rspec (3.5.0)
49
+ rspec-core (~> 3.5.0)
50
+ rspec-expectations (~> 3.5.0)
51
+ rspec-mocks (~> 3.5.0)
52
+ rspec-core (3.5.4)
53
+ rspec-support (~> 3.5.0)
54
+ rspec-expectations (3.5.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.5.0)
57
+ rspec-mocks (3.5.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.5.0)
60
+ rspec-support (3.5.0)
56
61
  slop (3.6.0)
57
62
  unf (0.1.4)
58
63
  unf_ext
@@ -65,7 +70,7 @@ DEPENDENCIES
65
70
  pry
66
71
  pry-stack_explorer
67
72
  right_chimp!
68
- rspec (~> 2.6.0)
73
+ rspec
69
74
 
70
75
  BUNDLED WITH
71
76
  1.13.2
data/chimp.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency 'right_api_client', '> 1.5'
25
25
  s.add_dependency 'highline', '~> 1.7.2'
26
26
 
27
- s.add_development_dependency 'rspec', '~> 2.6.0'
27
+ s.add_development_dependency 'rspec'
28
28
  s.add_development_dependency 'pry'
29
29
  s.add_development_dependency 'pry-stack_explorer'
30
30
 
@@ -128,13 +128,13 @@ module Chimp
128
128
  # Send the command to chimpd for execution
129
129
  #
130
130
  if @use_chimpd
131
- timestamp=Time.now.to_i
132
- length=6
133
- self.job_uuid = (36**(length-1) + rand(36**length - 36**(length-1))).to_s(36)
134
- ChimpDaemonClient.submit(@chimpd_host, @chimpd_port, self,self.job_uuid)
131
+ timestamp = Time.now.to_i
132
+ length = 6
133
+ self.job_uuid = (36**(length - 1) + rand(36**length - 36**(length - 1))).to_s(36)
134
+ ChimpDaemonClient.submit(@chimpd_host, @chimpd_port, self, job_uuid)
135
135
  exit
136
136
  else
137
- #Connect to the Api
137
+ # Connect to the Api
138
138
  Connection.instance
139
139
  if @interactive
140
140
  Connection.connect
@@ -9,7 +9,7 @@ module Chimp
9
9
 
10
10
  attr_accessor :verbose, :debug, :port, :concurrency, :delay, :retry_count,
11
11
  :dry_run, :logfile, :chimp_queue, :proc_counter, :semaphore,
12
- :bind_address
12
+ :bind_address, :server
13
13
  attr_reader :queue, :running
14
14
 
15
15
  include Singleton
@@ -18,7 +18,7 @@ module Chimp
18
18
  @verbose = false
19
19
  @debug = false
20
20
  @port = 9055
21
- @bind_address = "localhost"
21
+ @bind_address = 'localhost'
22
22
  @concurrency = 50
23
23
  @delay = 0
24
24
  @retry_count = 0
@@ -28,9 +28,9 @@ module Chimp
28
28
  @chimp_queue = Queue.new
29
29
  @semaphore = Mutex.new
30
30
 
31
- @proc_counter= 0
31
+ @proc_counter = 0
32
32
 
33
- #Connect to the API
33
+ # Connect to the API
34
34
  Connection.instance
35
35
  end
36
36
 
@@ -41,8 +41,8 @@ module Chimp
41
41
  install_signal_handlers
42
42
  parse_command_line
43
43
 
44
- #puts "chimpd #{VERSION} launching with #{@concurrency} workers"
45
- puts "Loading... please wait"
44
+ # puts "chimpd #{VERSION} launching with #{@concurrency} workers"
45
+ Log.info 'Loading... please wait'
46
46
  spawn_queue_runner
47
47
  spawn_webserver
48
48
  spawn_chimpd_submission_processor
@@ -389,7 +389,6 @@ module Chimp
389
389
 
390
390
  if filter == 'create'
391
391
  ChimpQueue.instance.create_group(group_name, payload['type'], payload['concurrency'])
392
-
393
392
  elsif filter == 'retry'
394
393
  group = ChimpQueue[group_name.to_sym]
395
394
  raise WEBrick::HTTPStatus::NotFound, "Group not found" unless group
@@ -5,11 +5,10 @@ module Chimp
5
5
  class ExecArray < Executor
6
6
  def run
7
7
  run_with_retry do
8
- audit_entry = []
9
8
  options = @inputs
10
9
 
11
10
  if @timeout < 300
12
- Log.error "timeout was less than 5 minutes! resetting to 5 minutes"
11
+ Log.error 'timeout was less than 5 minutes! resetting to 5 minutes'
13
12
  @timeout = 300
14
13
  end
15
14
 
@@ -17,7 +16,7 @@ module Chimp
17
16
 
18
17
  if audit_entry
19
18
  audit_entry.each do |a|
20
- a.wait_for_completed("no audit link available",@timeout)
19
+ a.wait_for_completed('no audit link available', @timeout)
21
20
  end
22
21
  else
23
22
  Log.warn "No audit entries returned for job_id=#{@job_id}"
@@ -26,16 +25,15 @@ module Chimp
26
25
  end
27
26
 
28
27
  def describe_work
29
- return "ExecArray job_id=#{@job_id} script=\"#{@exec['right_script']['name']}\" server=\"#{@server['nickname']}\""
28
+ "ExecArray job_id=#{@job_id} script=\"#{@exec['right_script']['name']}\" server=\"#{@server['nickname']}\""
30
29
  end
31
30
 
32
31
  def info
33
- return @exec['right_script']['name']
32
+ @exec['right_script']['name']
34
33
  end
35
34
 
36
35
  def target
37
- return @server['nickname']
36
+ @server['nickname']
38
37
  end
39
-
40
38
  end
41
39
  end
@@ -5,7 +5,7 @@ module Chimp
5
5
  class ExecCallback < Executor
6
6
  def run
7
7
  response = RestClient.get @uri
8
- if response.code > 199 and response.code < 300
8
+ if response.code > 199 && response.code < 300
9
9
  return true
10
10
  else
11
11
  return false
File without changes
@@ -2,8 +2,8 @@
2
2
  # Run a RightScript
3
3
  #
4
4
  module Chimp
5
+ # Class that describes the execution for a rightscript
5
6
  class ExecRightScript < Executor
6
-
7
7
  attr_accessor :audit_entry_data, :audit_entry_url
8
8
 
9
9
  def run
@@ -15,7 +15,7 @@ module Chimp
15
15
  end
16
16
 
17
17
  run_with_retry do
18
- task=Task.new
18
+ task = Task.new
19
19
  task.tasker = @server.run_executable(@exec, options)
20
20
  @audit_entry_url = task.friendly_url
21
21
  task.wait_for_state('completed', @timeout)
@@ -36,6 +36,5 @@ module Chimp
36
36
  def target
37
37
  @server.nickname
38
38
  end
39
-
40
39
  end
41
40
  end
File without changes
File without changes
@@ -10,26 +10,27 @@ module Chimp
10
10
 
11
11
  def initialize
12
12
  @params = {
13
- "position"=>5,
14
- "right_script"=>{
15
- "created_at"=>"",
16
- "href"=>"dummy_href",
17
- "updated_at"=>"",
18
- "version"=>4,
19
- "is_head_version"=>false,
20
- "script"=>"",
21
- "name"=>"dummy_name",
22
- "description"=>"dummy_description"
23
- },
24
- "recipe"=>nil,
25
- "apply"=>"operational"
26
- }
27
- @delay = 0
13
+ 'position' => 5,
14
+ 'right_script' => {
15
+ 'created_at' => '',
16
+ 'href' => 'dummy_href',
17
+ 'updated_at' => '',
18
+ 'version' => 4,
19
+ 'is_head_version' => false,
20
+ 'script' => '',
21
+ 'name' => 'dummy_name',
22
+ 'description' => 'dummy_description'
23
+ },
24
+ 'recipe' => nil,
25
+ 'apply' => 'operational'
26
+ }
27
+ @delay = 0
28
28
  end
29
29
 
30
30
  def href
31
31
  @params['right_script']['href']
32
32
  end
33
+
33
34
  def name
34
35
  @params['right_script']['name']
35
36
  end
@@ -1,3 +1,3 @@
1
1
  module Chimp
2
- VERSION = "2.1.28"
2
+ VERSION = '2.2'
3
3
  end
data/lib/right_chimp.rb CHANGED
@@ -17,28 +17,29 @@ require 'right_api_client'
17
17
  require 'rest-client'
18
18
  require 'logger'
19
19
 
20
+ # Group all the requires for Chimp
20
21
  module Chimp
21
22
  require 'right_chimp/version'
22
- require 'right_chimp/Chimp'
23
- require 'right_chimp/Log'
24
- require 'right_chimp/IDManager'
25
-
26
- require 'right_chimp/daemon/ChimpDaemon'
27
- require 'right_chimp/daemon/ChimpDaemonClient'
28
-
29
- require 'right_chimp/queue/ChimpQueue'
30
- require 'right_chimp/queue/QueueWorker'
31
- require 'right_chimp/queue/ExecutionGroup'
32
-
33
- require 'right_chimp/exec/Executor'
34
- require 'right_chimp/exec/ExecArray'
35
- require 'right_chimp/exec/ExecRightScript'
36
- require 'right_chimp/exec/ExecSSH'
37
- require 'right_chimp/exec/ExecReport'
38
- require 'right_chimp/exec/ExecNoop'
39
-
40
- require 'right_chimp/resources/Connection'
41
- require 'right_chimp/resources/Executable'
42
- require 'right_chimp/resources/Server'
43
- require 'right_chimp/resources/Task'
23
+ require 'right_chimp/chimp'
24
+ require 'right_chimp/log'
25
+ require 'right_chimp/id_manager'
26
+
27
+ require 'right_chimp/daemon/chimp_daemon'
28
+ require 'right_chimp/daemon/chimp_daemon_client'
29
+
30
+ require 'right_chimp/queue/chimp_queue'
31
+ require 'right_chimp/queue/queue_worker'
32
+ require 'right_chimp/queue/execution_group'
33
+
34
+ require 'right_chimp/exec/executor'
35
+ require 'right_chimp/exec/exec_array'
36
+ require 'right_chimp/exec/exec_rightscript'
37
+ require 'right_chimp/exec/exec_ssh'
38
+ require 'right_chimp/exec/exec_report'
39
+ require 'right_chimp/exec/exec_noop'
40
+
41
+ require 'right_chimp/resources/connection'
42
+ require 'right_chimp/resources/executable'
43
+ require 'right_chimp/resources/server'
44
+ require 'right_chimp/resources/task'
44
45
  end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chimp::ChimpDaemonClient do
4
+ before(:all) do
5
+ @daemon = Chimp::ChimpDaemon.instance
6
+ @daemon.verbose = false
7
+ @daemon.concurrency = 3
8
+ @daemon.spawn_queue_runner
9
+ @daemon.spawn_webserver
10
+ end
11
+
12
+ after(:all) do
13
+ @daemon.server.shutdown
14
+ end
15
+
16
+ let(:chimp_object) do
17
+ c = Chimp::Chimp.new
18
+ c.job_uuid = '123456'
19
+ c
20
+ end
21
+
22
+ describe '#submit' do
23
+ it 'should be able to send a job to the daemon' do
24
+ expect(Chimp::ChimpDaemonClient.submit('localhost', '9055', chimp_object, '123456')).to eq(true)
25
+ end
26
+
27
+ it 'should increase the processing counter by 1' do
28
+ start_value = @daemon.proc_counter
29
+ Chimp::ChimpDaemonClient.submit('localhost', '9055', chimp_object, '123456')
30
+ difference = @daemon.proc_counter - start_value
31
+ expect(difference).to eq 1
32
+ end
33
+ end
34
+
35
+ # describe '#retrieve_job_info' do
36
+ # it 'should correctly get a job ' do
37
+ # binding.pry
38
+ # Chimp::ChimpDaemonClient.retrieve_job_info('localhost', '9055')
39
+ # end
40
+ # end
41
+
42
+ describe '#retrieve_group_info' do
43
+ it 'should retrieve a full group' do
44
+ r = Chimp::ChimpDaemonClient.retrieve_group_info('localhost', '9055', 'default', :running)
45
+ expect(r).to be_a(Array)
46
+ expect(r[0]).to be_a(Chimp::ExecRightScript)
47
+ end
48
+
49
+ it 'should fail if the group doesnt exist' do
50
+ expect {
51
+ Chimp::ChimpDaemonClient.retrieve_group_info('localhost', '9055', 'foobar', :running)
52
+ }.to raise_error(RestClient::ResourceNotFound)
53
+ end
54
+ end
55
+
56
+ # # this basically tests updating the status of a job
57
+ # describe '#set_job_status' do
58
+ # it 'should change the status of a job' do
59
+ # Chimp::ChimpDaemonClient.set_job_status('localhost', '9055', '0', :running)
60
+ # end
61
+ #
62
+ # it 'should be unable to update a job that doesnt exist' do
63
+ #
64
+ # end
65
+ # end
66
+
67
+ describe '#create_group' do
68
+ it 'should create a parallel group' do
69
+ expect(Chimp::ChimpDaemonClient.create_group('localhost', '9055', 'paragroup', :parallel, '3')).to eq(false)
70
+ expect(@daemon.queue.group['paragroup']).to be_a(Chimp::ParallelExecutionGroup)
71
+ expect(@daemon.queue.group['paragroup'].concurrency).to eq('3')
72
+ end
73
+
74
+ it 'should create a serial group' do
75
+ expect(Chimp::ChimpDaemonClient.create_group('localhost', '9055', 'serialgroup', :serial, '2')).to eq(false)
76
+ expect(@daemon.queue.group['serialgroup']).to be_a(Chimp::SerialExecutionGroup)
77
+ expect(@daemon.queue.group['serialgroup'].concurrency).to eq('2')
78
+ # FIXME: Concurrency doesnt seem to be applied correctly, serial group should have concurrency of 1
79
+ end
80
+ end
81
+ # describe '#retry_group'
82
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chimp::ChimpDaemon do
4
+ let(:daemon) do
5
+ Chimp::ChimpDaemon.instance
6
+ end
7
+
8
+ describe '#initialize' do
9
+ it 'is a ChimpDaemon object' do
10
+ expect(daemon).to be_a Chimp::ChimpDaemon
11
+ end
12
+
13
+ it 'has a ChimpQueue object inside @queue' do
14
+ expect(daemon.queue).to be_a Chimp::ChimpQueue
15
+ end
16
+ end
17
+
18
+ describe '#run' do
19
+ # it 'should be able to spawn a webserver'
20
+ # it 'should be able to run forever'
21
+ # it 'should spawn a queue runner'
22
+ # it 'should run_forever'
23
+ end
24
+
25
+ describe '#parse_command_line' do
26
+ it 'should parse all parameters' do
27
+ string = '--logfile=/tmp/test --verbose --concurrency=34 --port=9056'
28
+ ARGV = string.split(' ')
29
+ daemon.parse_command_line
30
+ expect(daemon.concurrency).to eq 34
31
+ expect(daemon.logfile).to eq '/tmp/test'
32
+ expect(daemon.verbose).to eq true
33
+ expect(daemon.port).to eq '9056'
34
+ end
35
+ end
36
+
37
+ describe '#spawn_webserver' do
38
+ it 'should spawn a webserver' do
39
+ daemon.spawn_webserver
40
+ expect(daemon.server).to be_a WEBrick::HTTPServer
41
+ end
42
+ end
43
+
44
+ describe '#run_forever' do
45
+ end
46
+
47
+ describe '#install_signal_handlers' do
48
+ end
49
+
50
+ describe '#quit' do
51
+ end
52
+
53
+ describe '#spawn_chimpd_submission_processor' do
54
+ end
55
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Chimp::ExecRightScript do
4
+ let(:e) do
5
+ e = Chimp::ExecRightScript.new
6
+ e.job_uuid = '123456'
7
+ e.time_start = Time.now
8
+ e.time_end = e.time_start + 2
9
+ # Need to setup e.exec
10
+ e.exec = Chimp::Executable.new
11
+ e.server = Chimp::Server.new
12
+ e
13
+ end
14
+
15
+ before(:all) do
16
+ end
17
+
18
+ describe '#run' do
19
+ it 'should pause' do
20
+ # FIXME: probably need to workout some api stub/mocking
21
+ end
22
+ end
23
+
24
+ describe '#describe_work' do
25
+ it 'should return the formatted output' do
26
+ expect(e.describe_work).to be_a(String)
27
+ end
28
+ end
29
+
30
+ describe '#info' do
31
+ it 'should be able to tell you the name' do
32
+ expect(e.info).to be_a(String)
33
+ end
34
+ end
35
+
36
+ describe '#target' do
37
+ it 'should return the name of the server' do
38
+ expect(e.target).to be_a(String)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,7 @@
1
+ #
2
+ # Test ChimpQueue
3
+ #
4
+ require 'right_chimp'
5
+ require 'rspec'
6
+
7
+ ENV['TEST'] = 'true'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_chimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.28
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - RightScale Operations
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-11 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 2.6.0
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 2.6.0
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -148,20 +148,20 @@ files:
148
148
  - docker/right_chimp.sh
149
149
  - lib/right_chimp.rb
150
150
  - lib/right_chimp/Chimp.rb
151
- - lib/right_chimp/IDManager.rb
152
151
  - lib/right_chimp/Log.rb
153
- - lib/right_chimp/daemon/ChimpDaemon.rb
154
- - lib/right_chimp/daemon/ChimpDaemonClient.rb
155
- - lib/right_chimp/exec/ExecArray.rb
156
- - lib/right_chimp/exec/ExecCallback.rb
157
- - lib/right_chimp/exec/ExecNoop.rb
158
- - lib/right_chimp/exec/ExecReport.rb
159
- - lib/right_chimp/exec/ExecRightScript.rb
160
- - lib/right_chimp/exec/ExecSSH.rb
152
+ - lib/right_chimp/daemon/chimp_daemon.rb
153
+ - lib/right_chimp/daemon/chimp_daemon_client.rb
161
154
  - lib/right_chimp/exec/Executor.rb
162
- - lib/right_chimp/queue/ChimpQueue.rb
163
- - lib/right_chimp/queue/ExecutionGroup.rb
164
- - lib/right_chimp/queue/QueueWorker.rb
155
+ - lib/right_chimp/exec/exec_array.rb
156
+ - lib/right_chimp/exec/exec_callback.rb
157
+ - lib/right_chimp/exec/exec_noop.rb
158
+ - lib/right_chimp/exec/exec_report.rb
159
+ - lib/right_chimp/exec/exec_rightscript.rb
160
+ - lib/right_chimp/exec/exec_ssh.rb
161
+ - lib/right_chimp/id_manager.rb
162
+ - lib/right_chimp/queue/chimp_queue.rb
163
+ - lib/right_chimp/queue/execution_group.rb
164
+ - lib/right_chimp/queue/queue_worker.rb
165
165
  - lib/right_chimp/resources/Connection.rb
166
166
  - lib/right_chimp/resources/Executable.rb
167
167
  - lib/right_chimp/resources/Server.rb
@@ -173,14 +173,10 @@ files:
173
173
  - lib/right_chimp/templates/invertedhotdogstand.css
174
174
  - lib/right_chimp/templates/styleswitcher.js
175
175
  - lib/right_chimp/version.rb
176
- - spec/spec_chimp.rb
177
- - spec/spec_chimp_commandline.rb
178
- - spec/spec_chimpd.rb
179
- - spec/spec_chimpd_client.rb
180
- - spec/spec_execution_group.rb
181
- - spec/spec_queue.rb
182
- - spec/spec_queue_worker.rb
183
- - spec/spec_selection.rb
176
+ - spec/chimp_daemon_client_spec.rb
177
+ - spec/chimp_daemon_spec.rb
178
+ - spec/exec_righscript_spec.rb
179
+ - spec/spec_helper.rb
184
180
  homepage: https://github.com/rightscale/right_chimp
185
181
  licenses:
186
182
  - MIT
@@ -206,11 +202,7 @@ signing_key:
206
202
  specification_version: 4
207
203
  summary: RightScale platform command-line tool
208
204
  test_files:
209
- - spec/spec_chimp.rb
210
- - spec/spec_chimp_commandline.rb
211
- - spec/spec_chimpd.rb
212
- - spec/spec_chimpd_client.rb
213
- - spec/spec_execution_group.rb
214
- - spec/spec_queue.rb
215
- - spec/spec_queue_worker.rb
216
- - spec/spec_selection.rb
205
+ - spec/chimp_daemon_client_spec.rb
206
+ - spec/chimp_daemon_spec.rb
207
+ - spec/exec_righscript_spec.rb
208
+ - spec/spec_helper.rb
data/spec/spec_chimp.rb DELETED
@@ -1,20 +0,0 @@
1
- #
2
- # Test chimpd client
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
-
6
- require 'lib/right_chimp.rb'
7
- require 'rspec'
8
- require 'pp'
9
-
10
- include Chimp
11
-
12
- describe Chimp::ExecRightScript do
13
- it "can select servers with a tag query" do
14
- c = Chimp::Chimp.new
15
- c.tags = ["info:deployment=moo:localring91"]
16
- c.script = "SYS DNSMadeEasy Register Addresses"
17
- c.dry_run = false
18
- c.run
19
- end
20
- end
@@ -1,55 +0,0 @@
1
- #
2
- # Test chimpd client
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
- require 'pp'
8
-
9
- include Chimp
10
-
11
- chimp_command = "CHIMP_TEST=true bundle exec bin/chimp --noprompt"
12
- test_tag = "--tag='info:deployment=moo:localring91'"
13
- test_script = "--script='SYS DNSMadeEasy Register Addresses'"
14
-
15
- describe Chimp::Chimp do
16
- #
17
- # Selection options
18
- #
19
- #it "should not prompt when there is no action" do
20
- # data =`CHIMP_TEST=true bundle exec bin/chimp #{test_tag}`
21
- # $?.should == 0
22
- # data.match("No actions to perform.").should != nil
23
- #end
24
-
25
- #
26
- # RightScript execution
27
- #
28
- it "should run a rightscript with a tag query" do
29
- system("#{chimp_command} #{test_tag} #{test_script}")
30
- $?.should == 0
31
- end
32
-
33
- it "should run scripts on an array with a concurrency of 1 and a delay of 5" do
34
- system("#{chimp_command} --array='Core91' --concurrency=1 --delay=5 --script='SYS MAIL postfix configuration'")
35
- $?.should == 0
36
- end
37
-
38
- it "should run scripts on an array with a concurrency of 4 and a delay of 0" do
39
- system("#{chimp_command} --array='Core94' --array='Core91' --concurrency=4 --delay=0 --script='SYS MAIL postfix configuration'")
40
- $?.should == 0
41
- end
42
-
43
- #
44
- # chimpd submission
45
- #
46
-
47
- #it "should run a rightscript with a tag query via chimpd" do
48
- # system('CHIMP_TEST=true bundle exec bin/chimpd')
49
- # system('CHIMP_TEST=true bundle exec bin/chimp --chimpd --dry-run --noprompt --tag="info:deployment=moo:localring91" --script="SYS DNSMadeEasy Register Addresses"')
50
- # $?.should == 0
51
- # system('CHIMP_TEST=true bundle exec bin/chimpd --quit')
52
- #end
53
- end
54
-
55
-
data/spec/spec_chimpd.rb DELETED
@@ -1,33 +0,0 @@
1
- #
2
- # Test chimpd
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
- require 'pp'
8
-
9
- include Chimp
10
-
11
- uri =
12
-
13
- describe Chimp::ChimpDaemon do
14
- before :all do
15
- @c = ChimpDaemon.instance
16
- @c.spawn_queue_runner
17
- @c.spawn_webserver
18
- end
19
-
20
- #
21
- # .spawn_queue_runner
22
- #
23
- it "should have 50 threads" do
24
- ChimpQueue.instance.max_threads.should == 50
25
- end
26
-
27
- #
28
- # .quit
29
- #
30
- after :all do
31
- @c.quit
32
- end
33
- end
@@ -1,44 +0,0 @@
1
- #
2
- # Test chimpd client
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
- require 'pp'
8
-
9
- include Chimp
10
-
11
- host = "localhost"
12
- port = "9055"
13
-
14
- describe Chimp::ChimpDaemonClient do
15
- before :all do
16
- @c = ChimpDaemon.new
17
- @c.verbose = false
18
- @c.concurrency = 3
19
- @c.spawn_queue_runner
20
- @c.spawn_webserver
21
- end
22
-
23
- after :all do
24
- @c.quit if @c
25
- end
26
-
27
- #it "can quit a chimpd" do
28
- # response_code = ChimpDaemonClient.quit(host, port)
29
- # response_code.should == 200
30
- #end
31
-
32
- #
33
- # .submit
34
- #
35
- it "can submit work to chimpd" do
36
- c = Chimp::Chimp.new
37
- c.tags = ["service:auditor=true"]
38
- c.script = "SYS DNSMadeEasy Register Addresses"
39
- c.dry_run = false
40
- ChimpDaemonClient.submit(host, port, c)
41
- end
42
-
43
- end
44
-
@@ -1,135 +0,0 @@
1
- #
2
- # Test QueueWorker
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
-
8
- include Chimp
9
-
10
- describe SerialExecutionGroup do
11
- before :each do
12
- @eg = SerialExecutionGroup.new(:test)
13
- end
14
-
15
- #
16
- # .ready?
17
- #
18
- it "should be ready when it has work in its queue" do
19
- @eg.ready?.should == false
20
- @eg.push(ExecNoop.new(:job_id => 0))
21
- @eg.ready?.should == true
22
- end
23
-
24
- it "should not be ready while a job is executing" do
25
- @eg.push(ExecNoop.new(:job_id => 0))
26
- @eg.push(ExecNoop.new(:job_id => 1))
27
- @eg.get_job(0).status = Executor::STATUS_RUNNING
28
- @eg.ready?.should == false
29
- end
30
-
31
- #
32
- # .done?
33
- #
34
- it "should not be done when it has work in its queue" do
35
- @eg.done?.should == true
36
- @eg.push(ExecNoop.new(:job_id => 0))
37
- @eg.done?.should == false
38
- end
39
-
40
- #
41
- # .size
42
- #
43
- it "should be able to report the correct number of items in its queue" do
44
- @eg.push(ExecNoop.new(:job_id => 0))
45
- @eg.push(ExecNoop.new(:job_id => 1))
46
- @eg.push(ExecNoop.new(:job_id => 2))
47
- @eg.push(ExecNoop.new(:job_id => 3))
48
- @eg.push(ExecNoop.new(:job_id => 4))
49
-
50
- @eg.size.should == 5
51
-
52
- @eg.shift
53
- @eg.size.should == 4
54
-
55
- @eg.shift
56
- @eg.size.should == 3
57
- end
58
-
59
- #
60
- # .sort!
61
- #
62
- it "should be able to sort its queue by server name" do
63
- @eg.push(ExecNoop.new(:job_id => 1, :server => { "nickname" => "BBB", "name" => "BBB"}))
64
- @eg.push(ExecNoop.new(:job_id => 1, :server => { "nickname" => "CCC", "name" => "CCC"}))
65
- @eg.push(ExecNoop.new(:job_id => 0, :server => { "nickname" => "AAA", "name" => "AAA"}))
66
- @eg.sort!
67
- end
68
-
69
- #
70
- # .running?
71
- #
72
- it "should tell us whether it is running" do
73
- @eg.running?.should == false
74
- @eg.push(ExecNoop.new(:job_id => 0))
75
- @eg.running?.should == true
76
- end
77
-
78
- #
79
- # .requeue(id)
80
- #
81
- it "should requeue jobs correctly" do
82
- @eg.push(ExecNoop.new(:job_id => 0))
83
- @eg.reset!
84
- @eg.size.should == 0
85
- @eg.requeue(0)
86
- @eg.size.should == 1
87
- end
88
-
89
- #
90
- # .requeue_failed_jobs
91
- #
92
- it "should requeue all failed jobs" do
93
- @eg.push(ExecNoop.new(:job_id => 0))
94
- @eg.reset!
95
- @eg.size.should == 0
96
-
97
- @eg.get_job(0).status = Executor::STATUS_ERROR
98
- @eg.requeue_failed_jobs!
99
- @eg.size.should == 1
100
- end
101
-
102
- #
103
- # .cancel(id)
104
- #
105
- it "should cancel a job" do
106
- @eg.push(ExecNoop.new(:job_id => 0))
107
- @eg.size.should == 1
108
- @eg.cancel(0)
109
- @eg.size.should == 0
110
- end
111
-
112
- end
113
-
114
- describe ParallelExecutionGroup do
115
- before :each do
116
- @eg = ParallelExecutionGroup.new(:test)
117
- end
118
-
119
- #
120
- # .ready?
121
- #
122
- it "should be ready when it has work in its queue" do
123
- @eg.ready?.should == false
124
- @eg.push(ExecNoop.new(:job_id => 0))
125
- @eg.push(ExecNoop.new(:job_id => 1))
126
- @eg.ready?.should == true
127
- end
128
-
129
- it "should be ready while a job is executing" do
130
- @eg.push(ExecNoop.new(:job_id => 0))
131
- @eg.push(ExecNoop.new(:job_id => 1))
132
- @eg.get_job(0).status = Executor::STATUS_RUNNING
133
- @eg.ready?.should == true
134
- end
135
- end
data/spec/spec_queue.rb DELETED
@@ -1,37 +0,0 @@
1
- #
2
- # Test ChimpQueue
3
- #
4
-
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
-
8
- include Chimp
9
-
10
- describe ChimpQueue do
11
- before :all do
12
- @queue = ChimpQueue.instance
13
- @queue.max_threads = 3
14
- @queue.start
15
- end
16
-
17
- before :each do
18
- @queue.reset!
19
- end
20
-
21
- it "should accept work" do
22
- @queue.push(:default, ExecNoop.new(:job_id => 0))
23
- @queue.group[:default].get_job(0).status.should == Executor::STATUS_NONE
24
- end
25
-
26
- it "should distribute work" do
27
- @queue.push(:default, ExecNoop.new(:job_id => 0))
28
- @queue.shift.status.should == Executor::STATUS_NONE
29
- end
30
-
31
- it "should process the queue" do
32
- @queue.push(:default, ExecNoop.new(:job_id => 0))
33
- @queue.wait_until_done(:default) { }
34
- @queue.group[:default].get_job(0).status.should == Executor::STATUS_DONE
35
- end
36
- end
37
-
@@ -1,30 +0,0 @@
1
- #
2
- # Test QueueWorker
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
-
8
- include Chimp
9
-
10
- describe QueueWorker do
11
- it "should instantiate" do
12
- q = QueueWorker.new
13
- q.delay = 10
14
- q.retry_count = 10
15
- q.never_exit = false
16
-
17
- ChimpQueue.instance.group = {}
18
-
19
- q.delay.should == 10
20
- q.retry_count.should == 10
21
- q.never_exit.should == false
22
- end
23
-
24
- #it "should run" do
25
- # q = QueueWorker.new
26
- # q.run
27
- #end
28
-
29
- end
30
-
@@ -1,33 +0,0 @@
1
- #
2
- # Test Chimp
3
- #
4
- $LOAD_PATH << File.dirname(__FILE__) + "/.."
5
- require 'lib/right_chimp.rb'
6
- require 'rspec'
7
-
8
- describe Chimp::Chimp do
9
- before :each do
10
- @c = Chimp::Chimp.new
11
- @c.quiet = true
12
- @c.prompt = false
13
- @c.progress = false
14
- @c.interactive = false
15
- end
16
-
17
- it "performs a tag query" do
18
- @c.tags = ['service:dataservice=true']
19
- @c.run
20
- @c.servers.size.should > 0
21
- end
22
-
23
- it "performs a deployment query" do
24
- @c.deployment_names = ['moo:globalring']
25
- @c.run
26
- @c.servers.size.should > 0
27
- end
28
-
29
- it "performs an array query" do
30
- @c.array_names = ['Chimp Test Array']
31
- @c.run
32
- end
33
- end