syncwrap 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +30 -0
  3. data/Manifest.txt +14 -0
  4. data/README.rdoc +15 -5
  5. data/Rakefile +3 -14
  6. data/lib/syncwrap/base.rb +1 -1
  7. data/lib/syncwrap/components/amazon_linux.rb +50 -0
  8. data/lib/syncwrap/components/arch.rb +37 -0
  9. data/lib/syncwrap/components/bundle.rb +111 -0
  10. data/lib/syncwrap/components/bundled_iyyov_daemon.rb +130 -0
  11. data/lib/syncwrap/components/bundler_gem.rb +47 -0
  12. data/lib/syncwrap/components/centos.rb +28 -0
  13. data/lib/syncwrap/components/cruby_vm.rb +3 -6
  14. data/lib/syncwrap/components/debian.rb +89 -0
  15. data/lib/syncwrap/components/hashdot.rb +6 -4
  16. data/lib/syncwrap/components/iyyov.rb +2 -2
  17. data/lib/syncwrap/components/jruby_vm.rb +9 -5
  18. data/lib/syncwrap/components/network.rb +44 -24
  19. data/lib/syncwrap/components/open_jdk.rb +23 -7
  20. data/lib/syncwrap/components/postgresql.rb +77 -31
  21. data/lib/syncwrap/components/puma.rb +146 -0
  22. data/lib/syncwrap/components/qpid.rb +1 -1
  23. data/lib/syncwrap/components/rake_gem.rb +46 -0
  24. data/lib/syncwrap/components/rhel.rb +7 -3
  25. data/lib/syncwrap/components/run_user.rb +7 -3
  26. data/lib/syncwrap/components/source_tree.rb +128 -0
  27. data/lib/syncwrap/components/tarpit_gem.rb +60 -0
  28. data/lib/syncwrap/components/ubuntu.rb +14 -55
  29. data/lib/syncwrap/components/users.rb +1 -2
  30. data/lib/syncwrap/distro.rb +5 -5
  31. data/lib/syncwrap/ruby_support.rb +20 -4
  32. data/lib/syncwrap/version_support.rb +62 -0
  33. data/lib/syncwrap.rb +11 -0
  34. data/sync/postgresql/postgresql.conf.erb +4 -4
  35. data/sync/var/iyyov/default/bundled_daemon.rb.erb +31 -0
  36. data/test/test_components.rb +77 -18
  37. data/test/test_version_support.rb +65 -0
  38. metadata +16 -2
data/lib/syncwrap.rb CHANGED
@@ -357,8 +357,15 @@ module SyncWrap
357
357
  # risky in SyncWrap given that all of these should be loaded before
358
358
  # any threads are in play.
359
359
 
360
+ autoload :AmazonLinux, 'syncwrap/components/amazon_linux'
361
+ autoload :Bundle, 'syncwrap/components/bundle'
362
+ autoload :BundledIyyovDaemon, 'syncwrap/components/bundled_iyyov_daemon'
363
+ autoload :BundlerGem, 'syncwrap/components/bundler_gem'
364
+ autoload :Arch, 'syncwrap/components/arch'
365
+ autoload :CentOS, 'syncwrap/components/centos'
360
366
  autoload :CommercialJDK, 'syncwrap/components/commercial_jdk'
361
367
  autoload :CRubyVM, 'syncwrap/components/cruby_vm'
368
+ autoload :Debian, 'syncwrap/components/debian'
362
369
  autoload :EtcHosts, 'syncwrap/components/etc_hosts'
363
370
  autoload :Geminabox, 'syncwrap/components/geminabox'
364
371
  autoload :Hashdot, 'syncwrap/components/hashdot'
@@ -369,10 +376,14 @@ module SyncWrap
369
376
  autoload :Network, 'syncwrap/components/network'
370
377
  autoload :OpenJDK, 'syncwrap/components/open_jdk'
371
378
  autoload :PostgreSQL, 'syncwrap/components/postgresql'
379
+ autoload :Puma, 'syncwrap/components/puma'
372
380
  autoload :Qpid, 'syncwrap/components/qpid'
373
381
  autoload :QpidRepo, 'syncwrap/components/qpid'
382
+ autoload :RakeGem, 'syncwrap/components/rake_gem'
374
383
  autoload :RHEL, 'syncwrap/components/rhel'
375
384
  autoload :RunUser, 'syncwrap/components/run_user'
385
+ autoload :SourceTree, 'syncwrap/components/source_tree'
386
+ autoload :TarpitGem, 'syncwrap/components/tarpit_gem'
376
387
  autoload :Ubuntu, 'syncwrap/components/ubuntu'
377
388
  autoload :Users, 'syncwrap/components/users'
378
389
 
@@ -38,18 +38,18 @@
38
38
  # option or PGDATA environment variable, represented here as ConfigDir.
39
39
 
40
40
  <% if pg_specify_etc_config %>
41
- data_directory = '/var/lib/postgresql/<%= version %>/main'
41
+ data_directory = '/var/lib/postgresql/<%= pg_version %>/main'
42
42
  # use data in another directory
43
43
  # (change requires restart)
44
- hba_file = '/etc/postgresql/<%= version %>/main/pg_hba.conf'
44
+ hba_file = '/etc/postgresql/<%= pg_version %>/main/pg_hba.conf'
45
45
  # host-based authentication file
46
46
  # (change requires restart)
47
- ident_file = '/etc/postgresql/<%= version %>/main/pg_ident.conf'
47
+ ident_file = '/etc/postgresql/<%= pg_version %>/main/pg_ident.conf'
48
48
  # ident configuration file
49
49
  # (change requires restart)
50
50
 
51
51
  # If external_pid_file is not explicitly set, no extra PID file is written.
52
- external_pid_file = '/var/run/postgresql/<%= version %>-main.pid'
52
+ external_pid_file = '/var/run/postgresql/<%= pg_version %>-main.pid'
53
53
  # write an extra PID file
54
54
  # (change requires restart)
55
55
  <% else %>
@@ -0,0 +1,31 @@
1
+ Iyyov.context do |c|
2
+
3
+ c.define_daemon do |d|
4
+ d.name = "<%= name %>"
5
+ <% if instance %>
6
+ d.instance = "<%= instance %>"
7
+ <% end %>
8
+ d.exe_path = "<%= exe_path %>"
9
+ d.log_rotate
10
+
11
+ def d.start
12
+ epath = File.expand_path( exe_path, run_dir )
13
+ eargs = args.map { |a| a.to_s.strip }.compact
14
+ @log.info { ( [ "starting", epath ] + eargs ).join(' ') }
15
+ Dir.chdir( run_dir ) do
16
+ system( "<%= bundle_command %>",
17
+ 'exec',
18
+ exe_path,
19
+ *eargs ) or raise( Iyyov::DaemonFailed, "Start failed with #{$?}" )
20
+ end
21
+ @state = :up
22
+ true
23
+ rescue Iyyov::DaemonFailed, Errno::ENOENT => e
24
+ @log.error( "On exec", e )
25
+ @state = :failed
26
+ false
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -32,29 +32,57 @@ module SyncWrap
32
32
  # non-trivial differentiation.
33
33
  AUTO_TESTS =
34
34
  [ [ RHEL, CommercialJDK ],
35
- [ Ubuntu, CRubyVM ],
36
- [ RHEL, CRubyVM ],
35
+ [ Debian ],
36
+ [ Debian, CRubyVM ],
37
+ [ CentOS, CRubyVM ],
37
38
  [ EtcHosts ],
38
- [ RHEL, JRubyVM, RunUser, Iyyov, Geminabox ],
39
- [ Ubuntu, OpenJDK, JRubyVM, Hashdot ],
39
+ [ AmazonLinux, JRubyVM, RunUser, Iyyov, Geminabox ],
40
+ [ RHEL, JRubyVM, BundlerGem ],
41
+ [ RHEL, CRubyVM, BundlerGem ],
42
+ [ CentOS, JRubyVM, RakeGem ],
43
+ [ RHEL, CRubyVM, RakeGem ],
44
+ [ RHEL, RunUser, SourceTree,
45
+ source_dir: 'lib', require_clean: false ],
46
+ [ Debian, CRubyVM, BundlerGem, RunUser, Bundle,
47
+ bundle_path: File.expand_path( '../../lib', __FILE__ ) ],
48
+ [ AmazonLinux, RunUser, CRubyVM, BundlerGem,
49
+ SourceTree, { source_dir: 'lib', require_clean: false },
50
+ Bundle ],
51
+ [ Ubuntu, RunUser, JRubyVM, BundlerGem, Iyyov,
52
+ SourceTree, { source_dir: 'lib', require_clean: false },
53
+ Bundle, BundledIyyovDaemon ],
54
+ [ Ubuntu, RunUser, CRubyVM, BundlerGem, Puma,
55
+ puma_version: '2.9.0', rack_path: File.expand_path( '../../lib', __FILE__ ) ],
56
+ [ RHEL, RunUser, JRubyVM, BundlerGem,
57
+ SourceTree, { source_dir: 'lib', require_clean: false },
58
+ Bundle, Puma ],
59
+ [ Debian, OpenJDK, JRubyVM, Hashdot ],
40
60
  [ RHEL, JRubyVM, RunUser, Iyyov ],
41
61
  [ Ubuntu, JRubyVM, RunUser, Iyyov, IyyovDaemon, name: 'test', version: '0' ],
42
- [ RHEL, JRubyVM ],
62
+ [ CentOS, JRubyVM ],
43
63
  [ RHEL, MDRaid, raw_devices: 1 ],
44
- [ Ubuntu, MDRaid, raw_devices: 2 ],
64
+ [ Debian, MDRaid, raw_devices: 2 ],
65
+ [ Debian, Network ],
45
66
  [ Ubuntu, Network ],
46
67
  [ RHEL, Network ],
47
- [ Ubuntu, OpenJDK ],
68
+ [ RHEL, { rhel_version: '7' }, Network ],
69
+ [ AmazonLinux, Network ],
70
+ [ Debian, OpenJDK ],
71
+ [ Debian, PostgreSQL ],
48
72
  [ Ubuntu, PostgreSQL ],
49
- [ RHEL, PostgreSQL ],
73
+ [ CentOS, PostgreSQL ],
50
74
  [ RHEL, Qpid ],
51
- [ RHEL, QpidRepo, qpid_prebuild_repo: 'http://localhost' ],
75
+ [ CentOS, QpidRepo, qpid_prebuild_repo: 'http://localhost' ],
52
76
  [ RHEL ],
53
77
  [ RunUser ],
54
- [ Ubuntu ],
78
+ [ RHEL, CRubyVM, TarpitGem ],
79
+ [ RHEL, JRubyVM, TarpitGem ],
80
+ [ RHEL, RunUser, JRubyVM, TarpitGem, user_install: true ],
55
81
  [ Users, home_users: [ 'bob' ] ] ]
56
82
 
83
+ # Test overrides to standard Context.
57
84
  class TestContext < Context
85
+ include Shell
58
86
  attr_accessor :commands
59
87
 
60
88
  def initialize( *args )
@@ -62,10 +90,34 @@ module SyncWrap
62
90
  super
63
91
  end
64
92
 
65
- def capture_stream( *args )
93
+ # Run bash on localhost in dryrun mode (-n), for basic syntax
94
+ # checking.
95
+ def run_shell( command, opts = {} )
96
+ opts = opts.merge( dryrun: true, coalesce: false, accept: [0] )
97
+ args = sh_args( command, opts )
98
+ capture_stream( args, host, :sh, opts )
66
99
  @commands << args
67
- [ 0, [] ]
100
+ nil
68
101
  end
102
+
103
+ # Run bash on localhost in dryrun mode (-n), for basic syntax
104
+ # checking. Return random selection of :accept return value and
105
+ # empty output text.
106
+ def capture_shell( command, opts = {} )
107
+ accept = opts[ :accept ] || [ 0 ]
108
+ opts = opts.merge( dryrun: true, coalesce: false, accept: [0] )
109
+ args = sh_args( command, opts )
110
+ capture_stream( args, host, :sh, opts )
111
+ @commands << args
112
+ [ accept[ rand( accept.length ) ], "" ]
113
+ end
114
+
115
+ # Don't run rsync. Return some or no changes at random.
116
+ def rsync( srcs, target, opts )
117
+ @commands << rsync_args( host, srcs, target, opts )
118
+ ( rand(2) == 1 ) ? [ :something ] : []
119
+ end
120
+
69
121
  end
70
122
 
71
123
  class TestComponents < MiniTest::Unit::TestCase
@@ -86,17 +138,24 @@ module SyncWrap
86
138
  define_method( "test_#{cname}_#{i}" ) do
87
139
  sp = Space.new
88
140
  host = sp.host( 'testhost' )
89
- comps.each do |dep|
90
- host.add( dep.new )
141
+ until comps.empty? do
142
+ dep_class = comps.shift
143
+ dep_class_opts = comps.first.is_a?( Hash ) ? comps.shift : {}
144
+ host.add( dep_class.new( dep_class_opts ) )
91
145
  end
92
146
  comp = comp_class.new( comp_class_opts )
93
147
  host.add( comp )
94
148
  pass
95
149
  if comp.respond_to?( :install )
96
- with_test_context( sp, host ) do |ctx|
97
- comp.install
98
- ctx.flush
99
- assert_operator( ctx.commands.length, :>, 0 )
150
+ # Repeatedly test for randomized permutations
151
+ 3.times do
152
+ with_test_context( sp, host ) do |ctx|
153
+ comp.install
154
+ ctx.flush
155
+ assert_operator( ctx.commands.length, :>, 0 )
156
+ # each command run is an effective assert
157
+ ctx.commands.length.times { pass }
158
+ end
100
159
  end
101
160
  end
102
161
  end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env jruby
2
+ #.hashdot.profile += jruby-shortlived
3
+
4
+ #--
5
+ # Copyright (c) 2011-2014 David Kellum
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License"); you
8
+ # may not use this file except in compliance with the License. You
9
+ # may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16
+ # implied. See the License for the specific language governing
17
+ # permissions and limitations under the License.
18
+ #++
19
+
20
+ require_relative 'setup'
21
+
22
+ require 'syncwrap/version_support'
23
+
24
+ class TestVersionSupport < MiniTest::Unit::TestCase
25
+ include SyncWrap::VersionSupport
26
+
27
+ def test_to_a
28
+ assert_equal( [ 1 ], version_string_to_a( [ 1 ] ) )
29
+ assert_equal( [ 1 ], version_string_to_a( '1' ) )
30
+ assert_equal( [ 'a' ], version_string_to_a( 'a' ) )
31
+ assert_equal( [ 1, 2 ], version_string_to_a( '1.2' ) )
32
+ assert_equal( [ 1, 'p2' ], version_string_to_a( '1.p2' ) )
33
+ assert_equal( [ 1, 2, 'p3' ], version_string_to_a( '1.2-p3' ) )
34
+ end
35
+
36
+ def test_gte
37
+ refute( version_gte?( [0], [1] ) )
38
+ assert( version_gte?( [1], [1] ) )
39
+ assert( version_gte?( [2], [1] ) )
40
+
41
+ refute( version_gte?( ['a'], ['b'] ) )
42
+ assert( version_gte?( ['b'], ['b'] ) )
43
+ assert( version_gte?( ['c'], ['b'] ) )
44
+
45
+ refute( version_gte?( [0], [1,0] ) )
46
+ refute( version_gte?( [0,1], [1,0] ) )
47
+ refute( version_gte?( [1], [1,0] ) )
48
+ assert( version_gte?( [1,0], [1,0] ) )
49
+ assert( version_gte?( [1,0,0], [1,0] ) )
50
+ assert( version_gte?( [1,1], [1,0] ) )
51
+
52
+ assert( version_gte?( [1,'a'], [1,'a'] ) )
53
+ assert( version_gte?( [1,'a',0], [1,'a'] ) )
54
+ assert( version_gte?( [1,'b'], [1,'a'] ) )
55
+
56
+ refute( version_gte?( [1,1], [1,'a'] ) )
57
+ end
58
+
59
+ def test_lte
60
+ assert( version_lt?( [0], [1] ) )
61
+ refute( version_lt?( [1], [1] ) )
62
+ refute( version_lt?( [2], [1] ) )
63
+ end
64
+
65
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syncwrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Kellum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2014-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -171,8 +171,15 @@ files:
171
171
  - lib/syncwrap/base.rb
172
172
  - lib/syncwrap/cli.rb
173
173
  - lib/syncwrap/component.rb
174
+ - lib/syncwrap/components/amazon_linux.rb
175
+ - lib/syncwrap/components/arch.rb
176
+ - lib/syncwrap/components/bundle.rb
177
+ - lib/syncwrap/components/bundled_iyyov_daemon.rb
178
+ - lib/syncwrap/components/bundler_gem.rb
179
+ - lib/syncwrap/components/centos.rb
174
180
  - lib/syncwrap/components/commercial_jdk.rb
175
181
  - lib/syncwrap/components/cruby_vm.rb
182
+ - lib/syncwrap/components/debian.rb
176
183
  - lib/syncwrap/components/etc_hosts.rb
177
184
  - lib/syncwrap/components/geminabox.rb
178
185
  - lib/syncwrap/components/hashdot.rb
@@ -183,9 +190,13 @@ files:
183
190
  - lib/syncwrap/components/network.rb
184
191
  - lib/syncwrap/components/open_jdk.rb
185
192
  - lib/syncwrap/components/postgresql.rb
193
+ - lib/syncwrap/components/puma.rb
186
194
  - lib/syncwrap/components/qpid.rb
195
+ - lib/syncwrap/components/rake_gem.rb
187
196
  - lib/syncwrap/components/rhel.rb
188
197
  - lib/syncwrap/components/run_user.rb
198
+ - lib/syncwrap/components/source_tree.rb
199
+ - lib/syncwrap/components/tarpit_gem.rb
189
200
  - lib/syncwrap/components/ubuntu.rb
190
201
  - lib/syncwrap/components/users.rb
191
202
  - lib/syncwrap/context.rb
@@ -198,6 +209,7 @@ files:
198
209
  - lib/syncwrap/rsync.rb
199
210
  - lib/syncwrap/ruby_support.rb
200
211
  - lib/syncwrap/shell.rb
212
+ - lib/syncwrap/version_support.rb
201
213
  - sync/etc/corosync/corosync.conf
202
214
  - sync/etc/corosync/uidgid.d/qpid
203
215
  - sync/etc/gemrc
@@ -220,6 +232,7 @@ files:
220
232
  - sync/src/hashdot/profiles/jruby.hdp.erb
221
233
  - sync/src/hashdot/profiles/shortlived.hdp
222
234
  - sync/usr/local/etc/qpidd.conf
235
+ - sync/var/iyyov/default/bundled_daemon.rb.erb
223
236
  - sync/var/iyyov/default/config.rb
224
237
  - sync/var/iyyov/default/daemon.rb.erb
225
238
  - sync/var/iyyov/jobs.rb.erb
@@ -236,6 +249,7 @@ files:
236
249
  - test/test_shell.rb
237
250
  - test/test_space.rb
238
251
  - test/test_space_main.rb
252
+ - test/test_version_support.rb
239
253
  - test/zfile
240
254
  homepage: http://github.com/dekellum/syncwrap
241
255
  licenses: []