syncwrap 1.5.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/History.rdoc +19 -0
- data/Manifest.txt +82 -34
- data/README.rdoc +96 -48
- data/Rakefile +0 -65
- data/bin/syncwrap +27 -0
- data/examples/LAYOUT.rdoc +70 -0
- data/examples/Rakefile +16 -0
- data/examples/ec2.rb +44 -0
- data/examples/hello.rb +14 -0
- data/examples/hello_binding.rb +27 -0
- data/examples/jruby.rb +11 -0
- data/examples/private/aws.json +4 -0
- data/examples/rput.rb +24 -0
- data/examples/sync/home/bob/.ssh/authorized_keys +1 -0
- data/examples/sync/tmp/sample.erb +3 -0
- data/lib/syncwrap/amazon_ec2.rb +236 -0
- data/lib/syncwrap/amazon_ws.rb +308 -0
- data/lib/syncwrap/base.rb +4 -2
- data/lib/syncwrap/cli.rb +328 -0
- data/lib/syncwrap/component.rb +443 -0
- data/lib/syncwrap/components/commercial_jdk.rb +76 -0
- data/lib/syncwrap/components/cruby_vm.rb +144 -0
- data/lib/syncwrap/components/etc_hosts.rb +44 -0
- data/lib/syncwrap/{geminabox.rb → components/geminabox.rb} +12 -17
- data/lib/syncwrap/components/hashdot.rb +97 -0
- data/lib/syncwrap/components/iyyov.rb +144 -0
- data/lib/syncwrap/components/iyyov_daemon.rb +125 -0
- data/lib/syncwrap/components/jruby_vm.rb +122 -0
- data/lib/syncwrap/components/mdraid.rb +204 -0
- data/lib/syncwrap/components/network.rb +99 -0
- data/lib/syncwrap/components/open_jdk.rb +70 -0
- data/lib/syncwrap/components/postgresql.rb +159 -0
- data/lib/syncwrap/components/qpid.rb +303 -0
- data/lib/syncwrap/components/rhel.rb +71 -0
- data/lib/syncwrap/components/run_user.rb +99 -0
- data/lib/syncwrap/components/ubuntu.rb +85 -0
- data/lib/syncwrap/components/users.rb +200 -0
- data/lib/syncwrap/context.rb +260 -0
- data/lib/syncwrap/distro.rb +53 -60
- data/lib/syncwrap/formatter.rb +149 -0
- data/lib/syncwrap/host.rb +134 -0
- data/lib/syncwrap/main.rb +62 -0
- data/lib/syncwrap/path_util.rb +55 -0
- data/lib/syncwrap/rsync.rb +227 -0
- data/lib/syncwrap/ruby_support.rb +110 -0
- data/lib/syncwrap/shell.rb +207 -0
- data/lib/syncwrap.rb +367 -1
- data/{etc → sync/etc}/gemrc +1 -3
- data/sync/etc/hosts.erb +8 -0
- data/{etc/init.d/iyyov → sync/etc/init.d/iyyov.erb} +35 -7
- data/sync/etc/sysconfig/pgsql/postgresql.erb +2 -0
- data/sync/src/hashdot/Makefile.erb +98 -0
- data/sync/src/hashdot/profiles/default.hdp.erb +25 -0
- data/sync/src/hashdot/profiles/jruby-common.hdp +28 -0
- data/sync/src/hashdot/profiles/jruby-shortlived.hdp +9 -0
- data/sync/src/hashdot/profiles/jruby.hdp.erb +13 -0
- data/sync/src/hashdot/profiles/shortlived.hdp +6 -0
- data/sync/var/iyyov/default/config.rb +1 -0
- data/sync/var/iyyov/default/daemon.rb.erb +15 -0
- data/sync/var/iyyov/jobs.rb.erb +4 -0
- data/test/muddled_sync.rb +13 -0
- data/test/setup.rb +39 -0
- data/test/sync/d1/bar +1 -0
- data/test/sync/d1/foo.erb +1 -0
- data/test/sync/d3/d2/bar +1 -0
- data/test/sync/d3/d2/foo.erb +1 -0
- data/test/test_components.rb +108 -0
- data/test/test_context.rb +107 -0
- data/test/test_context_rput.rb +289 -0
- data/test/test_rsync.rb +138 -0
- data/test/test_shell.rb +233 -0
- data/test/test_space.rb +218 -0
- data/test/test_space_main.rb +40 -0
- data/test/zfile +1 -0
- metadata +204 -71
- data/etc/sysconfig/pgsql/postgresql +0 -2
- data/lib/syncwrap/aws.rb +0 -448
- data/lib/syncwrap/common.rb +0 -161
- data/lib/syncwrap/ec2.rb +0 -59
- data/lib/syncwrap/hashdot.rb +0 -70
- data/lib/syncwrap/iyyov.rb +0 -139
- data/lib/syncwrap/java.rb +0 -61
- data/lib/syncwrap/jruby.rb +0 -118
- data/lib/syncwrap/postgresql.rb +0 -135
- data/lib/syncwrap/qpid.rb +0 -251
- data/lib/syncwrap/remote_task.rb +0 -199
- data/lib/syncwrap/rhel.rb +0 -67
- data/lib/syncwrap/ubuntu.rb +0 -78
- data/lib/syncwrap/user_run.rb +0 -102
- data/test/test_syncwrap.rb +0 -202
- data/var/iyyov/jobs.rb +0 -11
- /data/{etc → sync/etc}/corosync/corosync.conf +0 -0
- /data/{etc → sync/etc}/corosync/uidgid.d/qpid +0 -0
- /data/{etc → sync/etc}/init.d/qpidd +0 -0
- /data/{etc → sync/etc}/sysctl.d/61-postgresql-shm.conf +0 -0
- /data/{usr/local → sync/jruby}/bin/jgem +0 -0
- /data/{postgresql → sync/postgresql}/rhel/pg_hba.conf +0 -0
- /data/{postgresql → sync/postgresql}/rhel/pg_ident.conf +0 -0
- /data/{postgresql → sync/postgresql}/rhel/postgresql.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/environment +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/pg_ctl.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/pg_hba.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/pg_ident.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/postgresql.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/start.conf +0 -0
- /data/{usr → sync/usr}/local/etc/qpidd.conf +0 -0
data/sync/etc/hosts.erb
ADDED
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
|
|
2
|
+
<% if lsb %>
|
|
3
|
+
### BEGIN INIT INFO
|
|
4
|
+
# Provides: iyyov
|
|
5
|
+
# Required-Start: $remote_fs $syslog
|
|
6
|
+
# Required-Stop: $remote_fs $syslog
|
|
7
|
+
# Should-Start: $named
|
|
8
|
+
# Default-Start: 2 3 4 5
|
|
9
|
+
# Default-Stop:
|
|
10
|
+
# Short-Description: Iyyov jruby monitor
|
|
11
|
+
# Description: Iyyov jruby monitoring and job control daemon
|
|
12
|
+
### END INIT INFO
|
|
13
|
+
|
|
14
|
+
. /lib/lsb/init-functions
|
|
15
|
+
<% else %>
|
|
3
16
|
# iyyov Startup script for Iyyov monitoring daemon
|
|
4
17
|
#
|
|
5
18
|
# chkconfig: 2345 88 12
|
|
6
|
-
# description: Iyyov monitoring daemon
|
|
19
|
+
# description: Iyyov monitoring and job control daemon
|
|
7
20
|
# processname: iyyov
|
|
8
21
|
# config: /opt/var/iyyov/jobs.rb
|
|
9
22
|
|
|
10
23
|
. /etc/rc.d/init.d/functions
|
|
24
|
+
<% end %>
|
|
11
25
|
|
|
12
26
|
# Gem home directory
|
|
13
27
|
# Set to match system "jgem environment path"
|
|
14
|
-
gem_home="
|
|
28
|
+
gem_home="<%= local_root %>/lib/jruby/gems"
|
|
15
29
|
|
|
16
30
|
# (Exact) Gem version of iyyov to run
|
|
17
|
-
version="
|
|
31
|
+
version="<%= iyyov_version %>"
|
|
18
32
|
|
|
19
33
|
# User to run the daemon as (should own rundir)
|
|
20
|
-
user="
|
|
34
|
+
user="<%= run_user %>"
|
|
21
35
|
|
|
22
36
|
# Running directory (for jobs.rb config, log, and pid file)
|
|
23
|
-
rundir="
|
|
37
|
+
rundir="<%= run_dir %>/iyyov"
|
|
24
38
|
|
|
25
39
|
# Add PATH to jruby if non-standard
|
|
26
|
-
export PATH=$PATH
|
|
40
|
+
export PATH=$PATH:<%= local_root %>/bin
|
|
27
41
|
|
|
28
42
|
prog="iyyov"
|
|
29
43
|
daemon="${gem_home}/gems/iyyov-${version}-java/init/${prog}"
|
|
@@ -37,11 +51,18 @@ start() {
|
|
|
37
51
|
[ -f "$config" ] || exit 6
|
|
38
52
|
[ -d "$rundir" ] || exit 7
|
|
39
53
|
|
|
54
|
+
<% if lsb %>
|
|
55
|
+
log_daemon_msg "Starting Iyyov Daemon" "iyyov"
|
|
56
|
+
start-stop-daemon --start -d $rundir -c $user --exec $daemon -- $config
|
|
57
|
+
RETVAL=$?
|
|
58
|
+
log_end_msg $RETVAL
|
|
59
|
+
<% else %>
|
|
40
60
|
echo -n $"Starting $prog: "
|
|
41
61
|
runuser -c "cd $rundir && $daemon $config" $user
|
|
42
62
|
RETVAL=$?
|
|
43
63
|
[ $RETVAL -eq 0 ] && success $"$prog startup" || failure $"$prog startup"
|
|
44
64
|
echo
|
|
65
|
+
<% end %>
|
|
45
66
|
}
|
|
46
67
|
|
|
47
68
|
status() {
|
|
@@ -59,12 +80,19 @@ reload() {
|
|
|
59
80
|
}
|
|
60
81
|
|
|
61
82
|
stop() {
|
|
83
|
+
<% if lsb %>
|
|
84
|
+
log_daemon_msg "Stopping iyyov daemon" "iyyov"
|
|
85
|
+
start-stop-daemon --stop --quiet --oknodo --pidfile $pidfile
|
|
86
|
+
RETVAL=$?
|
|
87
|
+
log_end_msg $RETVAL
|
|
88
|
+
<% else %>
|
|
62
89
|
echo -n $"Shutting down $prog: "
|
|
63
90
|
killproc -p $pidfile $prog
|
|
64
91
|
RETVAL=$?
|
|
65
92
|
[ $RETVAL -eq 0 ] && success || failure
|
|
66
93
|
echo
|
|
67
94
|
return $RETVAL
|
|
95
|
+
<% end %>
|
|
68
96
|
}
|
|
69
97
|
|
|
70
98
|
case "$1" in
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# JDK used for compiling, a different one can be set at runtime,
|
|
2
|
+
# see profiles/default.hdp
|
|
3
|
+
JAVA_HOME=<%= jdk_dir %>
|
|
4
|
+
# Dependent on apache portable runtime (apr-devel-1.x apr-1.x)
|
|
5
|
+
APR_CONFIG=$(shell which apr-1-config)
|
|
6
|
+
|
|
7
|
+
# Install hashdot binaries to specified directory
|
|
8
|
+
INSTALL_BIN=<%= local_root %>/bin
|
|
9
|
+
|
|
10
|
+
# The set of symlinks (from all below) to install
|
|
11
|
+
INSTALL_SYMLINKS = jruby
|
|
12
|
+
|
|
13
|
+
# Where to install and find profiles (*.hdp)
|
|
14
|
+
# export PROFILE_DIR=./profiles to work in source directory
|
|
15
|
+
PROFILE_DIR?=<%= local_root %>/lib/hashdot/profiles
|
|
16
|
+
|
|
17
|
+
VERSION=1.4.0
|
|
18
|
+
|
|
19
|
+
CC=gcc
|
|
20
|
+
CFLAGS=$(shell ${APR_CONFIG} --cflags --cppflags --includes) -O2 -Wall -fno-strict-aliasing -g \
|
|
21
|
+
-I$(JAVA_HOME)/include \
|
|
22
|
+
-I$(JAVA_HOME)/include/linux \
|
|
23
|
+
-DHASHDOT_PROFILE_DIR=\"${PROFILE_DIR}\" \
|
|
24
|
+
-DHASHDOT_VERSION=\"${VERSION}\"
|
|
25
|
+
|
|
26
|
+
LDFLAGS=$(shell ${APR_CONFIG} --ldflags)
|
|
27
|
+
|
|
28
|
+
# Override platform default (i.e. Mac defaults x32)
|
|
29
|
+
# LDFLAGS += -m64
|
|
30
|
+
|
|
31
|
+
LDLIBS=$(shell ${APR_CONFIG} --libs --link-ld)
|
|
32
|
+
|
|
33
|
+
ALL_SYMLINKS = clj jruby jython groovy rhino scala
|
|
34
|
+
|
|
35
|
+
all: hashdot
|
|
36
|
+
|
|
37
|
+
OBJS = runtime.o daemon.o jvm.o libpath.o main.o pidfile.o property.o
|
|
38
|
+
|
|
39
|
+
hashdot: $(OBJS)
|
|
40
|
+
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)
|
|
41
|
+
|
|
42
|
+
Makefile.deps : $(OBJS:%.o=%.c) *.h
|
|
43
|
+
$(CC) -MM $(CFLAGS) $(OBJS:%.o=%.c) > $@
|
|
44
|
+
|
|
45
|
+
# Install to INSTALL_BIN and PROFILE_DIR
|
|
46
|
+
install: hashdot
|
|
47
|
+
install -d $(PROFILE_DIR)
|
|
48
|
+
install -m 644 profiles/*.hdp $(PROFILE_DIR)
|
|
49
|
+
install -d $(INSTALL_BIN)
|
|
50
|
+
install -m 755 hashdot $(INSTALL_BIN)
|
|
51
|
+
cd $(INSTALL_BIN) && \
|
|
52
|
+
for sl in $(INSTALL_SYMLINKS); do \
|
|
53
|
+
test -e $$sl || ln -s hashdot $$sl; \
|
|
54
|
+
done
|
|
55
|
+
|
|
56
|
+
dist: hashdot
|
|
57
|
+
mkdir hashdot-$(VERSION)
|
|
58
|
+
cp -a INSTALL Makefile *.c *.h profiles test doc examples hashdot-$(VERSION)
|
|
59
|
+
tar --exclude '.svn' --exclude '*~' -zcvf hashdot-$(VERSION)-src.tar.gz hashdot-$(VERSION)
|
|
60
|
+
rm -rf hashdot-$(VERSION)
|
|
61
|
+
|
|
62
|
+
publish: dist
|
|
63
|
+
rsync -auP hashdot-$(VERSION)-src.tar.gz dekellum@frs.sourceforge.net:uploads/
|
|
64
|
+
rsync -aP --exclude ’*~’ doc/ dekellum,hashdot@web.sourceforge.net:/home/groups/h/ha/hashdot/htdocs/
|
|
65
|
+
|
|
66
|
+
$(ALL_SYMLINKS): hashdot
|
|
67
|
+
ln -sf hashdot $@
|
|
68
|
+
|
|
69
|
+
test/foo/Bar.class test/foobar.jar : test/foo/Bar.java
|
|
70
|
+
$(JAVA_HOME)/bin/javac $^
|
|
71
|
+
$(JAVA_HOME)/bin/jar -cf test/foobar.jar -C test foo
|
|
72
|
+
|
|
73
|
+
CPATH_TESTS = $(wildcard test/test_class_path_?.rb)
|
|
74
|
+
|
|
75
|
+
test: hashdot jruby test/foo/Bar.class test/foobar.jar
|
|
76
|
+
test/error/error_tests.sh
|
|
77
|
+
test/test_props.rb
|
|
78
|
+
test/test_env.rb
|
|
79
|
+
test/test_chdir.rb
|
|
80
|
+
@for tst in $(CPATH_TESTS); do echo $$tst; $$tst; done
|
|
81
|
+
test/test_daemon.rb
|
|
82
|
+
test/test_cmdline.rb param1 param2 || true
|
|
83
|
+
test/test_pid_file
|
|
84
|
+
|
|
85
|
+
# Requires all profiles working
|
|
86
|
+
EXAMPLES = $(wildcard examples/*)
|
|
87
|
+
test-examples : $(ALL_SYMLINKS)
|
|
88
|
+
@for example in $(EXAMPLES); do echo $$example; $$example; done
|
|
89
|
+
|
|
90
|
+
clean:
|
|
91
|
+
rm -rf hashdot-$(VERSION)-src.tar.gz hashdot hashdot.dSYM
|
|
92
|
+
rm -rf $(ALL_SYMLINKS)
|
|
93
|
+
rm -rf *.o
|
|
94
|
+
rm -rf test/foobar.jar
|
|
95
|
+
|
|
96
|
+
include Makefile.deps
|
|
97
|
+
|
|
98
|
+
.PHONY : test test-examples all install dist publish
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# HashDot default launch profile
|
|
2
|
+
# This profile is always read before any other profiles or hashdot
|
|
3
|
+
# properties.
|
|
4
|
+
|
|
5
|
+
## Setup the default JVM
|
|
6
|
+
|
|
7
|
+
# JVM install directory
|
|
8
|
+
hashdot.vm.home = <%= jdk_dir %>
|
|
9
|
+
|
|
10
|
+
# For Linux: amd64, i386, etc.
|
|
11
|
+
# Unused on Mac OS X
|
|
12
|
+
hashdot.vm.arch = amd64
|
|
13
|
+
|
|
14
|
+
# Mode: client, server
|
|
15
|
+
# client is unavailable on platforms like Linux amd64
|
|
16
|
+
# (See override in shortlived.hdp)
|
|
17
|
+
hashdot.vm.mode = server
|
|
18
|
+
|
|
19
|
+
# JVM library to Load
|
|
20
|
+
# Delay expansion (:=) to allow variable overrides
|
|
21
|
+
# Linux:
|
|
22
|
+
hashdot.vm.lib := ${hashdot.vm.home}/jre/lib/${hashdot.vm.arch}/${hashdot.vm.mode}/libjvm.so
|
|
23
|
+
# Mac: hashdot.vm.lib := ${hashdot.vm.home}/Libraries/lib${hashdot.vm.mode}.dylib
|
|
24
|
+
|
|
25
|
+
# user.timezone = America/Los_Angeles
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Common setting for multiple version of jruby.
|
|
2
|
+
|
|
3
|
+
# Identical defaults to jruby launcher
|
|
4
|
+
# These can still be overridden by the individual scripts
|
|
5
|
+
hashdot.vm.options += -Xmx768m -Xss1m
|
|
6
|
+
|
|
7
|
+
# Only jruby.jar is required for typical usage (scripts can require
|
|
8
|
+
# bsf.jar or JIP profiler if desired).
|
|
9
|
+
hashdot.vm.options += -Xbootclasspath/a:${jruby.lib}/jruby.jar
|
|
10
|
+
|
|
11
|
+
hashdot.main = org.jruby.Main
|
|
12
|
+
|
|
13
|
+
# Arguments following these flags are _not_ a script to scan for
|
|
14
|
+
# hashdot headers.
|
|
15
|
+
hashdot.parse_flags.value_args = -F -I -r
|
|
16
|
+
|
|
17
|
+
# Give up looking for a script header with any of these
|
|
18
|
+
hashdot.parse_flags.terminal = -C -e -S
|
|
19
|
+
|
|
20
|
+
#JFFI path
|
|
21
|
+
jffi.boot.library.path = ${jruby.home}/lib/native/x86_64-Linux
|
|
22
|
+
|
|
23
|
+
# Disable native extensions
|
|
24
|
+
# Note: Process.pid no longer works without native. Others?
|
|
25
|
+
# jruby.native.enabled = false
|
|
26
|
+
|
|
27
|
+
# JMX setup slows startup and wont be used
|
|
28
|
+
jruby.management.enabled = false
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# HashDot profile for shortlived jruby scripts.
|
|
2
|
+
#. hashdot.profile = jruby-shortlived
|
|
3
|
+
|
|
4
|
+
# Extends shortlived (client VM) and (jruby) profiles with further
|
|
5
|
+
# startup time tweeks.
|
|
6
|
+
hashdot.profile += jruby shortlived
|
|
7
|
+
|
|
8
|
+
# JMX setup slows startup and wont be used
|
|
9
|
+
jruby.management.enabled=false
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# HashDot launch profile for JRuby (http://jruby.codehaus.org/)
|
|
2
|
+
#. hashdot.profile = jruby
|
|
3
|
+
|
|
4
|
+
jruby.home = <%= jruby_dist_path %>
|
|
5
|
+
jruby.lib = ${jruby.home}/lib
|
|
6
|
+
jruby.script = jruby
|
|
7
|
+
jruby.shell = /bin/sh
|
|
8
|
+
jruby.bindir = <%= local_root %>/bin
|
|
9
|
+
|
|
10
|
+
hashdot.profile += jruby-common
|
|
11
|
+
|
|
12
|
+
# Rubygems Home (Install)
|
|
13
|
+
jruby.gem.home = <%= local_root %>/lib/jruby/gems
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Empty config installed by SyncWrap IyyovDaemon deployment
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Iyyov.context do |c|
|
|
2
|
+
|
|
3
|
+
c.define_daemon do |d|
|
|
4
|
+
d.name = "<%= name %>"
|
|
5
|
+
<% if gem_name != name %>
|
|
6
|
+
d.gem_name = "<%= gem_name %>"
|
|
7
|
+
<% end %>
|
|
8
|
+
<% if instance %>
|
|
9
|
+
d.instance = "<%= instance %>"
|
|
10
|
+
<% end %>
|
|
11
|
+
d.version = "= <%= version %>"
|
|
12
|
+
d.log_rotate
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
# This contrived sync file demonstrates evil method polution if loaded
|
|
3
|
+
# without the "wrap". See test_space_main.rb
|
|
4
|
+
|
|
5
|
+
include SyncWrap
|
|
6
|
+
|
|
7
|
+
# A method with name same as what IyyovDaemon#daemon_service_dir needs
|
|
8
|
+
# (and should be picked up via RunUser)
|
|
9
|
+
def service_dir( *args )
|
|
10
|
+
raise "This is bad!"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
host 'test', RunUser.new, IyyovDaemon.new( name: 'goo', version: '0.0.0' )
|
data/test/setup.rb
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#--
|
|
2
|
+
# Copyright (c) 2011-2014 David Kellum
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
|
5
|
+
# may not use this file except in compliance with the License. You
|
|
6
|
+
# may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
13
|
+
# implied. See the License for the specific language governing
|
|
14
|
+
# permissions and limitations under the License.
|
|
15
|
+
#++
|
|
16
|
+
|
|
17
|
+
require 'rubygems'
|
|
18
|
+
require 'bundler/setup'
|
|
19
|
+
|
|
20
|
+
require 'minitest/unit'
|
|
21
|
+
require 'minitest/autorun'
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
require_relative 'options.rb'
|
|
25
|
+
rescue LoadError
|
|
26
|
+
module TestOptions
|
|
27
|
+
# Set true if local password-less sudo works
|
|
28
|
+
SAFE_SUDO = false
|
|
29
|
+
|
|
30
|
+
# Set to host name for safe (non-modifying) SSH tests
|
|
31
|
+
SAFE_SSH = false
|
|
32
|
+
|
|
33
|
+
# Set true if SAFE_SSH also supports pasword-less sudo
|
|
34
|
+
SAFE_SSH_SUDO = false
|
|
35
|
+
|
|
36
|
+
# See test/sync.rb test/test_vms.rb
|
|
37
|
+
LOCAL_VM_TEST = false
|
|
38
|
+
end
|
|
39
|
+
end
|
data/test/sync/d1/bar
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bar
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bar<%= var %>bar
|
data/test/sync/d3/d2/bar
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bar
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bar<%= var %>bar
|
|
@@ -0,0 +1,108 @@
|
|
|
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'
|
|
23
|
+
|
|
24
|
+
module SyncWrap
|
|
25
|
+
|
|
26
|
+
# Each of the following are default auto test construction plans,
|
|
27
|
+
# for all components, used below. The last component is under test
|
|
28
|
+
# and run via #install if implemented. The prior components are
|
|
29
|
+
# known dependencies. A trailing Hash is used to populate required
|
|
30
|
+
# or test-worthy component options. RHEL and Ubuntu are used
|
|
31
|
+
# semi-randomly for <Distro> deps, or both are tested in the case of
|
|
32
|
+
# non-trivial differentiation.
|
|
33
|
+
AUTO_TESTS =
|
|
34
|
+
[ [ RHEL, CommercialJDK ],
|
|
35
|
+
[ Ubuntu, CRubyVM ],
|
|
36
|
+
[ RHEL, CRubyVM ],
|
|
37
|
+
[ EtcHosts ],
|
|
38
|
+
[ RHEL, JRubyVM, RunUser, Iyyov, Geminabox ],
|
|
39
|
+
[ Ubuntu, OpenJDK, JRubyVM, Hashdot ],
|
|
40
|
+
[ RHEL, JRubyVM, RunUser, Iyyov ],
|
|
41
|
+
[ Ubuntu, JRubyVM, RunUser, Iyyov, IyyovDaemon, name: 'test', version: '0' ],
|
|
42
|
+
[ RHEL, JRubyVM ],
|
|
43
|
+
[ RHEL, MDRaid, raw_devices: 1 ],
|
|
44
|
+
[ Ubuntu, MDRaid, raw_devices: 2 ],
|
|
45
|
+
[ Ubuntu, Network ],
|
|
46
|
+
[ RHEL, Network ],
|
|
47
|
+
[ Ubuntu, OpenJDK ],
|
|
48
|
+
[ Ubuntu, PostgreSQL ],
|
|
49
|
+
[ RHEL, PostgreSQL ],
|
|
50
|
+
[ RHEL, Qpid ],
|
|
51
|
+
[ RHEL, QpidRepo, qpid_prebuild_repo: 'http://localhost' ],
|
|
52
|
+
[ RHEL ],
|
|
53
|
+
[ RunUser ],
|
|
54
|
+
[ Ubuntu ],
|
|
55
|
+
[ Users, home_users: [ 'bob' ] ] ]
|
|
56
|
+
|
|
57
|
+
class TestContext < Context
|
|
58
|
+
attr_accessor :commands
|
|
59
|
+
|
|
60
|
+
def initialize( *args )
|
|
61
|
+
@commands = []
|
|
62
|
+
super
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def capture_stream( *args )
|
|
66
|
+
@commands << args
|
|
67
|
+
[ 0, [] ]
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class TestComponents < MiniTest::Unit::TestCase
|
|
72
|
+
|
|
73
|
+
def with_test_context( sp, host )
|
|
74
|
+
ctx = TestContext.new( host, sp.default_options )
|
|
75
|
+
ctx.with do
|
|
76
|
+
yield ctx
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
AUTO_TESTS.each_with_index do |comps, i|
|
|
81
|
+
comps = comps.dup
|
|
82
|
+
comp_class_opts = comps.last.is_a?( Hash ) ? comps.pop : {}
|
|
83
|
+
comp_class = comps.pop
|
|
84
|
+
cname = ( comp_class.name =~ /([a-zA-Z0-9]+)$/ ) && $1.downcase
|
|
85
|
+
|
|
86
|
+
define_method( "test_#{cname}_#{i}" ) do
|
|
87
|
+
sp = Space.new
|
|
88
|
+
host = sp.host( 'testhost' )
|
|
89
|
+
comps.each do |dep|
|
|
90
|
+
host.add( dep.new )
|
|
91
|
+
end
|
|
92
|
+
comp = comp_class.new( comp_class_opts )
|
|
93
|
+
host.add( comp )
|
|
94
|
+
pass
|
|
95
|
+
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 )
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
@@ -0,0 +1,107 @@
|
|
|
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'
|
|
23
|
+
|
|
24
|
+
class TestContext < MiniTest::Unit::TestCase
|
|
25
|
+
include SyncWrap
|
|
26
|
+
|
|
27
|
+
def sp
|
|
28
|
+
@sp ||= Space.new
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class TestContext < Context
|
|
32
|
+
attr_accessor :run_args
|
|
33
|
+
|
|
34
|
+
def run_shell( command, args )
|
|
35
|
+
@run_args = [ command, args ]
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_context_queue
|
|
40
|
+
host = sp.host( 'localhost' )
|
|
41
|
+
ctx = TestContext.new( host )
|
|
42
|
+
|
|
43
|
+
ctx.with do
|
|
44
|
+
ctx.sh( "c1", user: :root )
|
|
45
|
+
assert_nil( ctx.run_args )
|
|
46
|
+
ctx.sh( "c2", user: :root )
|
|
47
|
+
assert_nil( ctx.run_args )
|
|
48
|
+
ctx.flush
|
|
49
|
+
assert_equal( %w[c1 c2], ctx.run_args[0] )
|
|
50
|
+
assert_equal( { user: :root }, ctx.run_args[1] )
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_context_flush_at_end
|
|
55
|
+
host = sp.host( 'localhost' )
|
|
56
|
+
ctx = TestContext.new( host )
|
|
57
|
+
|
|
58
|
+
ctx.with do
|
|
59
|
+
ctx.sh( "c1", user: :root )
|
|
60
|
+
ctx.sh( "c2", user: :root )
|
|
61
|
+
assert_nil( ctx.run_args )
|
|
62
|
+
end
|
|
63
|
+
assert_equal( %w[c1 c2], ctx.run_args[0] )
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_context_flush_on_opts_change
|
|
67
|
+
host = sp.host( 'localhost' )
|
|
68
|
+
ctx = TestContext.new( host )
|
|
69
|
+
|
|
70
|
+
ctx.with do
|
|
71
|
+
ctx.sh( "c1", user: :root )
|
|
72
|
+
assert_nil( ctx.run_args )
|
|
73
|
+
ctx.sh( "c2" )
|
|
74
|
+
assert_equal( %w[c1], ctx.run_args[0] )
|
|
75
|
+
end
|
|
76
|
+
assert_equal( %w[c2], ctx.run_args[0] )
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_context_with_close
|
|
80
|
+
host = sp.host( 'localhost' )
|
|
81
|
+
ctx = TestContext.new( host )
|
|
82
|
+
|
|
83
|
+
ctx.with do
|
|
84
|
+
ctx.sh( "c1-", close: "-c3" ) do
|
|
85
|
+
ctx.sh( "c2" )
|
|
86
|
+
assert_nil( ctx.run_args )
|
|
87
|
+
end
|
|
88
|
+
assert_nil( ctx.run_args )
|
|
89
|
+
end
|
|
90
|
+
assert_equal( %w[c1- c2 -c3], ctx.run_args[0] )
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_context_nesting_error
|
|
94
|
+
host = sp.host( 'localhost' )
|
|
95
|
+
ctx = TestContext.new( host )
|
|
96
|
+
|
|
97
|
+
assert_raises( NestingError ) do
|
|
98
|
+
ctx.with do
|
|
99
|
+
ctx.sh( "c1-", close: "-c3" ) do
|
|
100
|
+
ctx.sh( "c2", user: :root )
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
assert_nil( ctx.run_args )
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|