rubber 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/CHANGELOG +98 -0
- data/LICENSE +10 -336
- data/lib/rubber/cloud/aws.rb +8 -8
- data/lib/rubber/commands/cron.rb +1 -1
- data/lib/rubber/commands/util.rb +46 -0
- data/lib/rubber/encryption.rb +46 -0
- data/lib/rubber/environment.rb +24 -5
- data/lib/rubber/recipes/rubber.rb +1 -1
- data/lib/rubber/recipes/rubber/instances.rb +97 -37
- data/lib/rubber/recipes/rubber/setup.rb +9 -4
- data/lib/rubber/recipes/rubber/static_ips.rb +3 -2
- data/lib/rubber/version.rb +1 -1
- data/rubber.gemspec +1 -2
- data/templates/apache/config/rubber/rubber-apache.yml +2 -2
- data/templates/base/config/deploy.rb +1 -1
- data/templates/base/config/rubber/common/crontab +1 -3
- data/templates/base/config/rubber/common/gemrc +5 -0
- data/templates/base/config/rubber/common/rubber.profile +0 -3
- data/templates/base/config/rubber/common/ruby.profile +9 -0
- data/templates/base/config/rubber/deploy-setup.rb +45 -65
- data/templates/base/config/rubber/rubber-ruby.yml +21 -0
- data/templates/base/config/rubber/rubber.yml +8 -3
- data/templates/base/script/rubber +7 -3
- data/templates/collectd/config/rubber/role/passenger/collectd-passenger.rb.conf +2 -2
- data/templates/collectd/config/rubber/role/passenger/passenger-status-sudoers.conf +2 -2
- data/templates/complete_unicorn_nginx/config/rubber/rubber-complete.yml +2 -3
- data/templates/complete_unicorn_nginx/templates.yml +0 -1
- data/templates/elasticsearch/config/rubber/deploy-elasticsearch.rb +1 -1
- data/templates/elasticsearch/config/rubber/rubber-elasticsearch.yml +1 -1
- data/templates/graphite/config/rubber/deploy-graphite.rb +9 -52
- data/templates/graphite/config/rubber/role/graphite_server/carbon.conf +1 -1
- data/templates/graphite/config/rubber/role/graphite_server/graphite-collectd-ping.conf +11 -0
- data/templates/graphite/config/rubber/role/graphite_server/monit-graphite_server.conf +8 -0
- data/templates/graphite/config/rubber/role/graphite_web/graphite_web-upstart.conf +15 -0
- data/templates/graphite/config/rubber/role/graphite_web/monit-graphite_web.conf +7 -0
- data/templates/graphite/config/rubber/role/graphite_web/uwsgi.ini +16 -0
- data/templates/graphite/config/rubber/rubber-graphite.yml +6 -4
- data/templates/graphite/templates.yml +2 -0
- data/templates/mongrel/config/rubber/deploy-mongrel.rb +1 -1
- data/templates/monit/config/rubber/role/mongrel/monit-mongrel.conf +2 -2
- data/templates/munin/config/rubber/role/munin/munin-plugins.conf +3 -3
- data/templates/munin/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
- data/templates/munin/config/rubber/role/passenger/munin-passenger-sudoers.conf +2 -2
- data/templates/munin/config/rubber/role/passenger/munin-passenger.conf +1 -1
- data/templates/munin/config/rubber/role/passenger_nginx/munin-passenger-memory.conf +1 -1
- data/templates/munin/config/rubber/role/passenger_nginx/munin-passenger-sudoers.conf +2 -2
- data/templates/munin/config/rubber/role/passenger_nginx/munin-passenger.conf +1 -1
- data/templates/passenger/config/rubber/deploy-passenger.rb +5 -11
- data/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +12 -0
- data/templates/passenger/config/rubber/rubber-passenger.yml +3 -3
- data/templates/passenger_nginx/config/rubber/role/passenger_nginx/nginx.conf +1 -1
- data/templates/passenger_nginx/config/rubber/rubber-passenger_nginx.yml +2 -2
- data/templates/postgresql/config/rubber/deploy-postgresql.rb +47 -0
- data/templates/redis/config/rubber/rubber-redis.yml +1 -1
- data/templates/resque/templates.yml +0 -1
- data/templates/sidekiq/config/rubber/deploy-sidekiq.rb +35 -0
- data/templates/sidekiq/config/rubber/role/sidekiq/monit-sidekiq.conf +10 -0
- data/templates/sidekiq/config/rubber/rubber-sidekiq.yml +2 -0
- data/templates/sidekiq/templates.rb +2 -0
- data/templates/sidekiq/templates.yml +4 -0
- data/templates/solr/config/rubber/common/solr_sunspot.yml +10 -0
- data/templates/solr/config/rubber/deploy-solr.rb +78 -0
- data/templates/solr/config/rubber/rubber-solr.yml +10 -0
- data/templates/solr/templates.yml +3 -0
- data/templates/sphinx/config/rubber/deploy-sphinx.rb +4 -4
- data/templates/torquebox/config/rubber/deploy-torquebox.rb +16 -4
- data/templates/torquebox/config/rubber/role/app/torquebox-apache-vhost.conf +15 -5
- data/templates/torquebox/config/rubber/role/torquebox/graylog-logging-module.xml +9 -0
- data/templates/torquebox/config/rubber/role/torquebox/standalone-ha.xml +25 -7
- data/templates/torquebox/config/rubber/role/torquebox/standalone.conf +2 -2
- data/templates/torquebox/config/rubber/rubber-torquebox.yml +6 -3
- data/templates/zookeeper/config/rubber/rubber-zookeeper.yml +1 -1
- data/test/command_test.rb +7 -5
- data/test/commands/cron_test.rb +22 -18
- data/test/commands/util_test.rb +40 -0
- data/test/encryption_test.rb +59 -0
- data/test/environment_test.rb +14 -0
- data/test/fixtures/obfuscated/rubber.yml +3 -0
- data/test/fixtures/obfuscated/secret.yml +1 -0
- metadata +33 -12
- data/templates/base/config/rubber/rubber-rvm.yml +0 -42
- data/templates/complete_passenger/templates.rb +0 -9
- data/templates/complete_passenger_nginx/templates.rb +0 -8
- data/templates/complete_unicorn_nginx/config/rubber/role/haproxy/haproxy-unicorn.conf +0 -21
- data/templates/complete_unicorn_nginx/templates.rb +0 -8
- data/templates/graphite/config/rubber/role/graphite_web/graphite-vhost.conf +0 -62
@@ -0,0 +1,10 @@
|
|
1
|
+
jdk: JDK_TAR_GZ_FILE_NAME
|
2
|
+
jdk_path: JDK_TAR_GZ_FILE_NAME_INC_FILE_NAME
|
3
|
+
solr_xml: SOLR_XML_FILE_NAME
|
4
|
+
solr_xml_path: SOLR_XML_FILE_PATH_AND_NAME
|
5
|
+
core_name: SOLR_CORE_NAME
|
6
|
+
tarz_config_files: PATH_TO_SOLR_CIONFIG_TAR_GZ_FILE
|
7
|
+
tomcat_dest_folder: TOMCAT7_DEST_FOLER
|
8
|
+
solr_home_dest_foler: SOLR_BASE_FOLDER
|
9
|
+
Xmx: HEAP_SPACE_FOR_JVM (e.g. 1024m or 2gb etc)
|
10
|
+
|
@@ -17,7 +17,7 @@ namespace :rubber do
|
|
17
17
|
|
18
18
|
task :custom_install, :roles => :sphinx do
|
19
19
|
# install sphinx from source
|
20
|
-
ver = "0.
|
20
|
+
ver = "2.0.6"
|
21
21
|
rubber.sudo_script 'install_sphinx', <<-ENDSCRIPT
|
22
22
|
# check if already installed
|
23
23
|
if [ -x /usr/local/bin/searchd ]
|
@@ -32,10 +32,10 @@ namespace :rubber do
|
|
32
32
|
TMPDIR=`mktemp -d` || exit 1
|
33
33
|
cd $TMPDIR
|
34
34
|
echo 'Downloading'
|
35
|
-
wget -qN http://
|
35
|
+
wget -qN http://sphinxsearch.com/files/sphinx-#{ver}-release.tar.gz
|
36
36
|
echo 'Unpacking'
|
37
|
-
tar xf sphinx-#{ver}.tar.gz
|
38
|
-
cd sphinx-#{ver}
|
37
|
+
tar xf sphinx-#{ver}-release.tar.gz
|
38
|
+
cd sphinx-#{ver}-release
|
39
39
|
./configure
|
40
40
|
make
|
41
41
|
make install
|
@@ -17,6 +17,15 @@ namespace :rubber do
|
|
17
17
|
rm -f #{rubber_env.torquebox_dir}
|
18
18
|
ln -s #{rubber_env.torquebox_prefix}/torquebox-#{rubber_env.torquebox_version} #{rubber_env.torquebox_dir}
|
19
19
|
|
20
|
+
# Create the log dir.
|
21
|
+
mkdir -p #{rubber_env.torquebox_log_dir}
|
22
|
+
chown -R #{rubber_env.app_user} #{rubber_env.torquebox_log_dir}
|
23
|
+
|
24
|
+
# Set up libraries for graylog logger.
|
25
|
+
mkdir -p #{rubber_env.torquebox_dir}/jboss/modules/org/graylog2/logging/main
|
26
|
+
wget -qNO "#{rubber_env.torquebox_dir}/jboss/modules/org/graylog2/logging/main/gelfj-1.0.1.jar" https://github.com/downloads/t0xa/gelfj/gelfj-1.0.1.jar
|
27
|
+
wget -qNO "#{rubber_env.torquebox_dir}/jboss/modules/org/graylog2/logging/main/json-simple-1.1.1.jar" http://json-simple.googlecode.com/files/json-simple-1.1.1.jar
|
28
|
+
|
20
29
|
# Cleanup after ourselves.
|
21
30
|
rm torquebox-dist-#{rubber_env.torquebox_version}-bin.zip
|
22
31
|
fi
|
@@ -46,11 +55,10 @@ namespace :rubber do
|
|
46
55
|
on :load do
|
47
56
|
rubber.serial_task self, :serial_reload, :roles => [:torquebox] do
|
48
57
|
rsudo "touch #{jboss_home}/standalone/deployments/#{application}-knob.yml.dodeploy"
|
58
|
+
rsudo "if ! ps ax | grep -v grep | grep -c torque &> /dev/null; then service torquebox start; fi"
|
49
59
|
|
50
60
|
# Wait for TorqueBox to startup before moving on so we don't remove all hosts from the cluster.
|
51
|
-
logger.info "Waiting for TorqueBox to
|
52
|
-
|
53
|
-
#rsudo "while ! curl -s -f http://$HOSTNAME:#{rubber_env.torquebox_http_port} &> /dev/null; do echo .; sleep 1; done"
|
61
|
+
logger.info "Waiting for TorqueBox to deploy"
|
54
62
|
|
55
63
|
# TorqueBox first "deploys" the app, then lets the web context startup. While it's deploying,
|
56
64
|
# the old context can still service requests. So, we need to wait until the app is deployed before we can
|
@@ -80,6 +88,10 @@ namespace :rubber do
|
|
80
88
|
rsudo "chown -R #{rubber_env.app_user}:#{rubber_env.app_user} #{shared_path}/cache"
|
81
89
|
end
|
82
90
|
|
91
|
+
before "deploy:stop", "rubber:torquebox:stop"
|
92
|
+
after "deploy:start", "rubber:torquebox:start"
|
93
|
+
after "deploy:restart", "rubber:torquebox:reload"
|
94
|
+
|
83
95
|
task :restart, :roles => :torquebox do
|
84
96
|
stop
|
85
97
|
start
|
@@ -90,7 +102,7 @@ namespace :rubber do
|
|
90
102
|
end
|
91
103
|
|
92
104
|
task :start, :roles => :torquebox do
|
93
|
-
rsudo "service torquebox start
|
105
|
+
rsudo "service torquebox start"
|
94
106
|
end
|
95
107
|
|
96
108
|
after "deploy:restart", "rubber:torquebox:reload"
|
@@ -1,6 +1,11 @@
|
|
1
1
|
<%
|
2
|
-
@path = "/etc/apache2/sites-available/#{rubber_env.app_name}-
|
3
|
-
@post = "a2enmod rewrite && a2enmod ssl && a2enmod expires && a2enmod xsendfile && a2ensite #{rubber_env.app_name}"
|
2
|
+
@path = "/etc/apache2/sites-available/#{rubber_env.app_name}-torquebox"
|
3
|
+
@post = "a2enmod rewrite && a2enmod ssl && a2enmod expires && a2enmod xsendfile && a2ensite #{rubber_env.app_name}-torquebox"
|
4
|
+
|
5
|
+
sidekiq_gem_path = if rubber_instances.for_role('sidekiq').any?
|
6
|
+
require 'sidekiq'
|
7
|
+
`find /mnt/#{rubber_env.app_name}-#{RUBBER_ENV}/shared/bundle -name sidekiq-#{Sidekiq::VERSION}`.strip
|
8
|
+
end
|
4
9
|
%>
|
5
10
|
|
6
11
|
NameVirtualHost *:<%= rubber_env.apache_listen_port %>
|
@@ -22,10 +27,12 @@ Listen <%= port %>
|
|
22
27
|
# Don't show haproxy checks in access log (see also apache2.conf)
|
23
28
|
SetEnvIf Request_URI "^/httpchk.txt$" dontlog
|
24
29
|
|
25
|
-
RailsEnv <%= Rubber.env %>
|
26
|
-
|
27
30
|
XSendFile on
|
28
31
|
|
32
|
+
<% if rubber_instances.for_role('sidekiq').any? %>
|
33
|
+
XSendFilePath <%= sidekiq_gem_path %>/web/assets
|
34
|
+
<% end %>
|
35
|
+
|
29
36
|
RewriteEngine On
|
30
37
|
RewriteCond %{HTTP_HOST} ^<%= rubber_env.domain %>$
|
31
38
|
RewriteRule ^(.*)$ http://www.<%= rubber_env.domain %>$1 [R,L]
|
@@ -48,6 +55,9 @@ Listen <%= port %>
|
|
48
55
|
# Cache the resource even if SSL is in use.
|
49
56
|
Header merge Cache-Control public
|
50
57
|
|
58
|
+
# Remove any cookies set with the request so we avoid them being cached in a CDN.
|
59
|
+
Header unset Set-Cookie
|
60
|
+
|
51
61
|
SetEnv no-gzip
|
52
62
|
</LocationMatch>
|
53
63
|
|
@@ -70,7 +80,7 @@ Listen <%= port %>
|
|
70
80
|
</FilesMatch>
|
71
81
|
<% end %>
|
72
82
|
|
73
|
-
<% if port == rubber_env.
|
83
|
+
<% if port == rubber_env.apache_listen_ssl_port %>
|
74
84
|
SSLEngine on
|
75
85
|
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
|
76
86
|
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%
|
2
|
+
@path = "#{rubber_env.torquebox_dir}/jboss/modules/org/graylog2/logging/main/module.xml"
|
3
|
+
%>
|
4
|
+
<module xmlns="urn:jboss:module:1.0" name="org.graylog2.logging">
|
5
|
+
<resources>
|
6
|
+
<resource-root path="gelfj-1.0.1.jar"/>
|
7
|
+
<resource-root path="json-simple-1.1.1.jar"/>
|
8
|
+
</resources>
|
9
|
+
</module>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<%
|
2
2
|
@path = "#{rubber_env.torquebox_dir}/jboss/standalone/configuration/standalone-ha.xml"
|
3
|
+
graylog_server = rubber_instances.for_role("graylog_server").first
|
3
4
|
%><?xml version='1.0' encoding='UTF-8'?>
|
4
5
|
<server xmlns='urn:jboss:domain:1.3'>
|
5
6
|
<extensions>
|
@@ -44,6 +45,7 @@
|
|
44
45
|
<extension module='org.torquebox.jobs'/>
|
45
46
|
<extension module='org.projectodd.polyglot.hasingleton'/>
|
46
47
|
<extension module='org.projectodd.polyglot.cache'/>
|
48
|
+
<extension module="org.projectodd.polyglot.stomp"/>
|
47
49
|
</extensions>
|
48
50
|
<system-properties>
|
49
51
|
<property name='org.apache.tomcat.util.http.ServerCookie.FWD_SLASH_IS_SEPARATOR' value='false'/>
|
@@ -92,6 +94,18 @@
|
|
92
94
|
<suffix value='.yyyy-MM-dd'/>
|
93
95
|
<append value='true'/>
|
94
96
|
</periodic-rotating-file-handler>
|
97
|
+
<% if graylog_server %>
|
98
|
+
<custom-handler name='GRAYLOG' class='org.graylog2.logging.GelfHandler' module='org.graylog2.logging'>
|
99
|
+
<level name='INFO'/>
|
100
|
+
<properties>
|
101
|
+
<property name='graylogHost' value='<%= graylog_server.full_name %>'/>
|
102
|
+
<property name='graylogPort' value='<%= rubber_env.graylog_server_port %>'/>
|
103
|
+
<property name='originHost' value='<%= rubber_env.host %>'/>
|
104
|
+
<property name='facility' value='torquebox'/>
|
105
|
+
<property name='extractStacktrace' value='true'/>
|
106
|
+
</properties>
|
107
|
+
</custom-handler>
|
108
|
+
<% end %>
|
95
109
|
<logger category='com.arjuna'>
|
96
110
|
<level name='WARN'/>
|
97
111
|
</logger>
|
@@ -112,6 +126,9 @@
|
|
112
126
|
<handlers>
|
113
127
|
<handler name='CONSOLE'/>
|
114
128
|
<handler name='FILE'/>
|
129
|
+
<% if graylog_server %>
|
130
|
+
<handler name='GRAYLOG'/>
|
131
|
+
<% end %>
|
115
132
|
</handlers>
|
116
133
|
</root-logger>
|
117
134
|
<logger category='org.jboss.jca.adapters.jdbc.extensions.mysql'>
|
@@ -222,9 +239,9 @@
|
|
222
239
|
<file-store/>
|
223
240
|
</replicated-cache>
|
224
241
|
<!--
|
225
|
-
|
226
|
-
|
227
|
-
|
242
|
+
~ Clustered cache used internally by EJB subsytem for managing the client-mapping(s) of
|
243
|
+
~ the socketbinding referenced by the EJB remoting connector
|
244
|
+
-->
|
228
245
|
<replicated-cache name='remote-connector-client-mappings' mode='SYNC' batching='true'/>
|
229
246
|
<distributed-cache name='dist' mode='ASYNC' batching='true' l1-lifespan='0'>
|
230
247
|
<eviction strategy='LRU' max-entries='10000'/>
|
@@ -566,7 +583,7 @@
|
|
566
583
|
<subsystem xmlns='urn:jboss:domain:torquebox-bootstrap:1.0'/>
|
567
584
|
<subsystem xmlns='urn:jboss:domain:torquebox-core:1.0'/>
|
568
585
|
<subsystem xmlns='urn:jboss:domain:torquebox-messaging:1.0'/>
|
569
|
-
<subsystem xmlns='urn:jboss:domain:torquebox-stomp:1.0'
|
586
|
+
<subsystem xmlns='urn:jboss:domain:torquebox-stomp:1.0'/>
|
570
587
|
<subsystem xmlns='urn:jboss:domain:torquebox-web:1.0'/>
|
571
588
|
<subsystem xmlns='urn:jboss:domain:torquebox-security:1.0'/>
|
572
589
|
<subsystem xmlns='urn:jboss:domain:torquebox-services:1.0'/>
|
@@ -574,6 +591,7 @@
|
|
574
591
|
<subsystem xmlns='urn:jboss:domain:torquebox-jobs:1.0'/>
|
575
592
|
<subsystem xmlns='urn:jboss:domain:polyglot-hasingleton:1.0'/>
|
576
593
|
<subsystem xmlns='urn:jboss:domain:polyglot-cache:1.0'/>
|
594
|
+
<subsystem xmlns="urn:jboss:domain:polyglot-stomp:1.0" socket-binding="stomp"/>
|
577
595
|
</profile>
|
578
596
|
<interfaces>
|
579
597
|
<interface name='management'>
|
@@ -585,9 +603,9 @@
|
|
585
603
|
<!-- TODO - only show this if the jacorb subsystem is added -->
|
586
604
|
<interface name='unsecure'>
|
587
605
|
<!--
|
588
|
-
|
589
|
-
|
590
|
-
|
606
|
+
~ Used for IIOP sockets in the standard configuration.
|
607
|
+
~ To secure JacORB you need to setup SSL
|
608
|
+
-->
|
591
609
|
<inet-address value='${jboss.bind.address.unsecure:127.0.0.1}'/>
|
592
610
|
</interface>
|
593
611
|
</interfaces>
|
@@ -51,7 +51,7 @@ fi
|
|
51
51
|
# Specify options to pass to the Java VM.
|
52
52
|
#
|
53
53
|
if [ "x$JAVA_OPTS" = "x" ]; then
|
54
|
-
JAVA_OPTS="-Xms64m -Xmx768m -
|
54
|
+
JAVA_OPTS="-Xms64m -Xmx768m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -server"
|
55
55
|
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS -Djava.awt.headless=true"
|
56
56
|
JAVA_OPTS="$JAVA_OPTS -Djboss.bind.address=<%= rubber_env.full_host %>"
|
57
57
|
JAVA_OPTS="$JAVA_OPTS -Djboss.mod_cluster.proxyList=<%= rubber_instances.for_role('web').collect { |host| "#{host.full_name}:80" }.join(',') %>"
|
@@ -74,7 +74,7 @@ fi
|
|
74
74
|
#JAVA_OPTS="$JAVA_OPTS -Djboss.modules.metrics=true"
|
75
75
|
|
76
76
|
|
77
|
-
JAVA_OPTS="$JAVA_OPTS $APPEND_JAVA_OPTS"
|
77
|
+
JAVA_OPTS="$JAVA_OPTS -Xss2048k -Djruby.compile.invokedynamic=false -Dorg.quartz.scheduler.skipUpdateCheck=true $APPEND_JAVA_OPTS"
|
78
78
|
|
79
79
|
# Prevent RVM from messing with TorqueBox loading.
|
80
80
|
unset GEM_PATH
|
@@ -1,4 +1,4 @@
|
|
1
|
-
torquebox_version: 2.
|
1
|
+
torquebox_version: 2.3.0
|
2
2
|
torquebox_prefix: /opt
|
3
3
|
torquebox_dir: "#{torquebox_prefix}/torquebox"
|
4
4
|
torquebox_log_dir: /var/log/torquebox
|
@@ -7,11 +7,14 @@ torquebox_http_port: 9090
|
|
7
7
|
torquebox_https_port: 9443
|
8
8
|
torquebox_ajp_port: 8009
|
9
9
|
|
10
|
-
backstage_user:
|
11
|
-
backstage_password:
|
10
|
+
backstage_user: admin
|
11
|
+
backstage_password: admin123
|
12
12
|
|
13
13
|
mod_cluster_version: 1.2.0
|
14
14
|
|
15
|
+
apache_listen_port: 80
|
16
|
+
apache_listen_ssl_port: 443
|
17
|
+
|
15
18
|
roles:
|
16
19
|
torquebox:
|
17
20
|
packages: [openjdk-7-jdk libaio1, unzip]
|
@@ -1,5 +1,5 @@
|
|
1
1
|
zookeeper_version: 3.3.6
|
2
|
-
zookeeper_package_url: "http://www.
|
2
|
+
zookeeper_package_url: "http://www.globalish.com/am/zookeeper/zookeeper-#{zookeeper_version}/zookeeper-#{zookeeper_version}.tar.gz"
|
3
3
|
zookeeper_install_dir: "/usr/local/zookeeper-#{zookeeper_version}"
|
4
4
|
zookeeper_data_dir: /mnt/zookeeper/data
|
5
5
|
zookeeper_pid_file: "#{zookeeper_data_dir}/zookeeper_server.pid"
|
data/test/command_test.rb
CHANGED
@@ -3,25 +3,27 @@ require File.expand_path(File.join(__FILE__, '..', 'test_helper'))
|
|
3
3
|
class CommandTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
6
|
+
@project_root = File.expand_path(File.join(__FILE__, '../..'))
|
7
|
+
@rubber = "#{@project_root}/bin/rubber"
|
8
|
+
ENV['RUBBER_ROOT'] = @project_root
|
7
9
|
end
|
8
10
|
|
9
11
|
def test_rubber_help
|
10
|
-
out =
|
12
|
+
out = `#{@rubber}`
|
11
13
|
assert out =~ /Subcommands:\n(.*)\nOptions:/m
|
12
14
|
subcommands = $1.scan(/^\s*(\S+)\s*/).flatten
|
13
|
-
assert_equal ["config", "cron", "util:rotate_logs", "util:backup", "util:backup_db", "util:restore_db", "vulcanize"].sort, subcommands.sort
|
15
|
+
assert_equal ["config", "cron", "util:rotate_logs", "util:backup", "util:backup_db", "util:obfuscation", "util:restore_db", "vulcanize"].sort, subcommands.sort
|
14
16
|
end
|
15
17
|
|
16
18
|
def test_rubber_help_size
|
17
|
-
out =
|
19
|
+
out = `#{@rubber} --help`
|
18
20
|
assert out.lines.all? {|l| l.size <= 81 }
|
19
21
|
|
20
22
|
assert out =~ /Subcommands:\n(.*)\nOptions:/m
|
21
23
|
subcommands = $1.scan(/^\s*(\S+)\s*/).flatten
|
22
24
|
assert subcommands.size > 0
|
23
25
|
subcommands.each do |s|
|
24
|
-
out =
|
26
|
+
out = `#{@rubber} #{s} --help`
|
25
27
|
assert out.lines.all? {|l| l.size <= 81 }, "help for #{s} exceeds 80 chars"
|
26
28
|
end
|
27
29
|
|
data/test/commands/cron_test.rb
CHANGED
@@ -3,24 +3,28 @@ require File.expand_path(File.join(__FILE__, '../..', 'test_helper'))
|
|
3
3
|
class CronTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
|
7
|
-
|
6
|
+
@project_root = File.expand_path(File.join(__FILE__, '../../..'))
|
7
|
+
@rubber_root = "#{@project_root}/test"
|
8
|
+
@rubber = "#{@project_root}/bin/rubber"
|
9
|
+
ENV['RUBBER_ROOT'] = @rubber_root
|
10
|
+
ENV['BUNDLE_GEMFILE'] = "#{@project_root}/Gemfile"
|
11
|
+
system("rm -f #{@rubber_root}/log/*.log")
|
8
12
|
end
|
9
13
|
|
10
14
|
def teardown
|
11
|
-
system("rm -f #{
|
15
|
+
system("rm -f #{@rubber_root}/log/*.log")
|
12
16
|
end
|
13
17
|
|
14
18
|
def test_rubber_cron_basic
|
15
19
|
date = Time.now.tv_sec.to_s
|
16
|
-
out =
|
20
|
+
out = `#{@rubber} cron echo #{date}`
|
17
21
|
|
18
22
|
assert_equal 0, $?
|
19
23
|
assert_equal "", out
|
20
24
|
|
21
|
-
logs = Dir["#{
|
25
|
+
logs = Dir["#{@rubber_root}/log/*.log"]
|
22
26
|
assert_equal 1, logs.size
|
23
|
-
assert_equal "#{
|
27
|
+
assert_equal "#{@rubber_root}/log/cron-sh-echo.log", logs.first
|
24
28
|
assert_match /rubber:cron running \["echo", "#{date}"\] at/, File.read(logs.first).strip
|
25
29
|
assert_match /\n#{date}$/, File.read(logs.first).strip
|
26
30
|
end
|
@@ -28,15 +32,15 @@ class CronTest < Test::Unit::TestCase
|
|
28
32
|
def test_rubber_cron_log_append
|
29
33
|
date = Time.now.tv_sec.to_s
|
30
34
|
|
31
|
-
out =
|
35
|
+
out = `#{@rubber} cron echo #{date}`
|
32
36
|
assert_equal 0, $?
|
33
37
|
assert_equal "", out
|
34
38
|
|
35
|
-
out =
|
39
|
+
out = `#{@rubber} cron echo #{date}`
|
36
40
|
assert_equal 0, $?
|
37
41
|
assert_equal "", out
|
38
42
|
|
39
|
-
logs = Dir["#{
|
43
|
+
logs = Dir["#{@rubber_root}/log/*.log"]
|
40
44
|
assert_equal 1, logs.size
|
41
45
|
running_lines = File.read(logs.first).lines.to_a.grep(/rubber:cron running/)
|
42
46
|
assert_equal 2, running_lines.size
|
@@ -44,38 +48,38 @@ class CronTest < Test::Unit::TestCase
|
|
44
48
|
|
45
49
|
def test_rubber_cron_logfile
|
46
50
|
date = Time.now.tv_sec.to_s
|
47
|
-
out =
|
48
|
-
logs = Dir["#{
|
51
|
+
out = `#{@rubber} cron -l #{@rubber_root}/log/foo.log -- echo #{date}`
|
52
|
+
logs = Dir["#{@rubber_root}/log/*.log"]
|
49
53
|
assert_equal 1, logs.size
|
50
|
-
assert_equal "#{
|
54
|
+
assert_equal "#{@rubber_root}/log/foo.log", logs.first
|
51
55
|
assert_match /\n#{date}$/, File.read(logs.first).strip
|
52
56
|
end
|
53
57
|
|
54
58
|
def test_rubber_cron_task_logfile
|
55
59
|
date = Time.now.tv_sec.to_s
|
56
|
-
out =
|
57
|
-
logs = Dir["#{
|
60
|
+
out = `#{@rubber} cron --task -- cron -o -- echo #{date}`
|
61
|
+
logs = Dir["#{@rubber_root}/log/cron-task*.log"]
|
58
62
|
assert_equal 1, logs.size
|
59
63
|
assert_match /\n#{date}$/, File.read(logs.first).strip
|
60
64
|
end
|
61
65
|
|
62
66
|
def test_rubber_cron_directory_changed
|
63
|
-
out =
|
67
|
+
out = `#{@rubber} cron -o -r /tmp -- pwd`
|
64
68
|
assert_match /(\/private)?\/tmp/, out, "Unexpected output:\n#{out}"
|
65
69
|
end
|
66
70
|
|
67
71
|
def test_rubber_cron_output_empty
|
68
|
-
out =
|
72
|
+
out = `#{@rubber} cron -- ls -la`
|
69
73
|
assert_equal "", out, "Unexpected output:\n#{out}"
|
70
74
|
end
|
71
75
|
|
72
76
|
def test_rubber_cron_output_echoed
|
73
|
-
out =
|
77
|
+
out = `#{@rubber} cron -o -- ls -la`
|
74
78
|
assert_not_equal "", out, "Unexpected output:\n#{out}"
|
75
79
|
end
|
76
80
|
|
77
81
|
def test_rubber_cron_output_on_error
|
78
|
-
out =
|
82
|
+
out = `#{@rubber} cron -- ls -la jkbhbj`
|
79
83
|
assert_not_equal 0, $?
|
80
84
|
assert_not_equal "", out, "Unexpected output:\n#{out}"
|
81
85
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path(File.join(__FILE__, '../..', 'test_helper'))
|
2
|
+
|
3
|
+
class UtilTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@project_root = File.expand_path(File.join(__FILE__, '../../..'))
|
7
|
+
@rubber = "#{@project_root}/bin/rubber"
|
8
|
+
@key = Rubber::Encryption.generate_encrypt_key
|
9
|
+
ENV['RUBBER_ROOT'] = @project_root
|
10
|
+
end
|
11
|
+
|
12
|
+
context "obfuscation" do
|
13
|
+
|
14
|
+
should "generate a key" do
|
15
|
+
out = `#{@rubber} util:obfuscation -g`
|
16
|
+
assert_equal 0, $?, "Process failed, output: #{out}"
|
17
|
+
assert_match /Obfuscation key: [^\n\s]+/, out
|
18
|
+
end
|
19
|
+
|
20
|
+
should "encrypt and decrypt rubber-secret.yml" do
|
21
|
+
pend('This is not yet working on JRuby.') if defined?(JRUBY_VERSION)
|
22
|
+
|
23
|
+
fixture_dir = File.expand_path("#{File.dirname(__FILE__)}/../fixtures/secret")
|
24
|
+
out = `#{@rubber} util:obfuscation -f '#{fixture_dir}/secret.yml' -k '#{@key}'`
|
25
|
+
assert_equal 0, $?, "Process failed, output: #{out}"
|
26
|
+
assert out.size > 0
|
27
|
+
assert_no_match /secret_key: secret_val/, out
|
28
|
+
|
29
|
+
tempfile = Tempfile.new('encryptedsecret')
|
30
|
+
open(tempfile.path, "w") {|f| f.write(out) }
|
31
|
+
|
32
|
+
out2 = `#{@rubber} util:obfuscation -f '#{tempfile.path}' -k '#{@key}' -d`
|
33
|
+
assert_equal 0, $?, "Process failed, output: #{out2}"
|
34
|
+
assert out2.size > 0
|
35
|
+
assert_match /secret_key: secret_val/, out2
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|