Skip to content

Instantly share code, notes, and snippets.

@jwadolowski
Last active August 29, 2015 14:24
Show Gist options
  • Save jwadolowski/136a2c0bb614eb7886d8 to your computer and use it in GitHub Desktop.
Save jwadolowski/136a2c0bb614eb7886d8 to your computer and use it in GitHub Desktop.
Specinfra issue with file content matching (affects any v2.36.17+, works fine for v2.36.16). Based on attached diff it seems that not the whole file is loaded, hence no match. To be even worse it occurs totally randomly (sometimes all green, sometimes 1-3 failuers). Test environment: CentOS 6.6 (http://opscode-vm-bento.s3.amazonaws.com/vagrant/v…
require 'serverspec'
set :backend, :exec
describe 'CQ author home directory' do
it 'exists' do
expect(file('/opt/cq/author')).to be_directory
end
it 'is owned by cq' do
expect(file('/opt/cq/author')).to be_owned_by('cq')
end
it 'is grouped into cq' do
expect(file('/opt/cq/author')).to be_grouped_into('cq')
end
it 'has 755 mode' do
expect(file('/opt/cq/author')).to be_mode('755')
end
end
describe 'CQ JAR file' do
it 'exists in author instance home dir' do
expect(
command('ls -l /opt/cq/author').stdout
).to match(/cq-quickstart-5\.6\.1\.jar/)
end
it 'contains proper content' do
expect(
command('grep -i adobe /opt/cq/author/cq-quickstart-5.6.1.jar').stdout
).to match('matches')
end
it 'is owned by cq' do
expect(file('/opt/cq/author/cq-quickstart-5.6.1.jar')).to be_owned_by('cq')
end
it 'is grouped into cq' do
expect(
file('/opt/cq/author/cq-quickstart-5.6.1.jar')
).to be_grouped_into('cq')
end
it 'is properly unpacked' do
expect(file('/opt/cq/author/crx-quickstart')).to be_directory
expect(file('/opt/cq/author/crx-quickstart')).to be_owned_by('cq')
expect(file('/opt/cq/author/crx-quickstart')).to be_grouped_into('cq')
end
end
describe 'CQ license file' do
it 'exists in author instance home' do
expect(file('/opt/cq/author/license.properties')).to be_file
end
it 'contains valid content' do
expect(
file('/opt/cq/author/license.properties').content
).to match('license.downloadID')
end
it 'is owned by cq' do
expect(file('/opt/cq/author/license.properties')).to be_owned_by('cq')
end
it 'is grouped into cq' do
expect(file('/opt/cq/author/license.properties')).to be_grouped_into('cq')
end
end
describe 'CQ init script' do
it 'exists' do
expect(file('/etc/init.d/cq56-author')).to be_file
end
it 'is executable' do
expect(file('/etc/init.d/cq56-author')).to be_executable
end
it 'is owned by root' do
expect(file('/etc/init.d/cq56-author')).to be_owned_by('root')
end
it 'is grouped into root' do
expect(file('/etc/init.d/cq56-author')).to be_grouped_into('root')
end
it 'contains PID_DIR line' do
expect(
file('/etc/init.d/cq56-author').content
).to match('PID_DIR="\$CQ_HOME/crx-quickstart/conf"')
end
it 'contains KILL_DELAY line' do
expect(
file('/etc/init.d/cq56-author').content
).to match('KILL_DELAY=120')
end
it 'contains sleep between stop and start' do
expect(
file('/etc/init.d/cq56-author').content
).to match('sleep 5')
end
it 'contains CQ_CONF_FILE variable for author' do
expect(
file('/etc/init.d/cq56-author').content
).to match(
'CQ_CONF_FILE=/opt/cq/author/crx-quickstart/conf/cq56-author.conf')
end
it 'does not contain CQ_CONF_FILE variable for publish' do
expect(
file('/etc/init.d/cq56-author').content
).not_to match(
'CQ_CONF_FILE=/opt/cq/author/crx-quickstart/conf/cq56-publish.conf')
end
end
describe 'CQ author config file' do
it 'exists' do
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf')
).to be_file
end
it 'is owned by cq' do
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf')
).to be_owned_by('cq')
end
it 'is grouped into cq' do
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf')
).to be_grouped_into('cq')
end
it 'contains valid content' do
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf').content
).to match('CQ_MIN_HEAP=256')
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf').content
).to match('export CQ_HOME=/opt/cq/author')
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf').content
).not_to match('export CQ_HOME=/opt/cq/publish')
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf').content
).to match('export CQ_PORT=4502')
expect(
file('/opt/cq/author/crx-quickstart/conf/cq56-author.conf').content
).not_to match('export CQ_PORT=4503')
end
end
describe 'CQ author service' do
it 'is running' do
expect(service('cq56-author')).to be_running
end
it 'is enabled' do
expect(service('cq56-author')).to be_enabled
end
end
describe 'CQ PID file' do
it 'exists' do
expect(file('/opt/cq/author/crx-quickstart/conf/cq.pid')).to be_file
end
it 'is owned by cq' do
expect(
file('/opt/cq/author/crx-quickstart/conf/cq.pid')
).to be_owned_by('cq')
end
it 'is grouped into cq' do
expect(
file('/opt/cq/author/crx-quickstart/conf/cq.pid')
).to be_grouped_into('cq')
end
end
describe 'CQ instance' do
it 'is working properly' do
expect(
command(
'curl http://localhost:4502/libs/granite/core/content/login.html'
).exit_status
).to eq 0
expect(
command(
'curl http://localhost:4502/libs/granite/core/content/login.html '\
'-sw "%{http_code}" -o /dev/null'
).stdout
).to match('200')
end
end
#!/bin/sh
#
# cq56-author Startup script for the Adobe CQ 5.6.1 Author instance
#
# chkconfig: - 20 80
# description: Adobe CQ is a Java-based web content management system
### BEGIN INIT INFO
# Provides: cq56-author
# Required-Start: $local_fs $network
# Required-Stop: $local_fs $network
# Short-Description: start and stop Adobe CQ 5.6.1 Author
# Description: Adobe CQ is a Java-based web content management system
### END INIT INFO
# Please make sure that the following file exists: /opt/cq/author/crx-quickstart/conf/cq56-author.conf
PROG=cq56-author
CQ_CONF_FILE=/opt/cq/author/crx-quickstart/conf/cq56-author.conf
# -----------------------------------------------------------------------------
# do not configure below this point
# -----------------------------------------------------------------------------
# Source function library
. /etc/rc.d/init.d/functions
# Soruce CQ configuration file
[ -e $CQ_CONF_FILE ] && . $CQ_CONF_FILE
# Add JAVA_HOME to the PATH variable if necessary
if [ -n "$JAVA_HOME" ]; then
EXP_PATH="export PATH=\"$JAVA_HOME/bin:$PATH\"; "
fi
# PID file
PID_DIR="$CQ_HOME/crx-quickstart/conf"
PID_FILE="$PID_DIR/cq.pid"
# Log directory
LOG_DIR="$CQ_HOME/crx-quickstart/logs"
# Execute path
EXEC=". $CQ_CONF_FILE; $EXP_PATH bash $CQ_HOME/crx-quickstart/bin/start 2>$LOG_DIR/start_error.log > $LOG_DIR/start.log"
# Kill delay
KILL_DELAY=120
lockfile=/var/lock/subsys/$PROG
start() {
[ -x $CQ_HOME/crx-quickstart/bin/start ] || exit 5
[ -f $CQ_CONF_FILE ] || exit 6
echo -n $"Starting $PROG: "
daemon --user=$CQ_USER --pidfile=$PID_FILE --check $PROG $EXEC
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $PROG: "
killproc -p $PID_FILE -d $KILL_DELAY $PROG
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
sleep 5
start
}
rh_status() {
status -p $PID_FILE $PROG
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
exit $?
16:57:30 1) CQ init script contains KILL_DELAY line
16:57:30 Failure/Error: file('/etc/init.d/cq56-publish').content
16:57:30 expected "#!/bin/sh\n#\n# cq56-publish Startup script for the Adobe CQ 5.6.1 Publish instance\n#\n# chkconfig: - 20 80\n# description: Adobe CQ is a Java-based web content management system\n\n### BEGIN INIT INFO\n# Provides: cq56-publish\n# Required-Start: $local_fs $network\n# Required-Stop: $local_fs $network\n# Short-Description: start and stop Adobe CQ 5.6.1 Publish\n# Description: Adobe CQ is a Java-based web content management system\n### END INIT INFO\n\n# Please make sure that the following file exists: /opt/cq/publish/crx-quickstart/conf/cq56-publish.conf\n\nPROG=cq56-publish\nCQ_CONF_FILE=/opt/cq/publish/crx-quickstart/conf/cq56-publish.conf\n\n# -----------------------------------------------------------------------------\n# do not configure below this point\n# -----------------------------------------------------------------------------\n\n# Source function library\n. /etc/rc.d/init.d/functions\n\n# Soruce CQ configuration file\n[ -e $CQ_CONF_FILE ] && . $CQ_CONF_FILE\n\n# Add JAVA_HOME to the PATH variable if" to match "KILL_DELAY=120"
16:57:30 Diff:
16:57:30 @@ -1,2 +1,32 @@
16:57:30 -KILL_DELAY=120
16:57:30 +#!/bin/sh
16:57:30 +#
16:57:30 +# cq56-publish Startup script for the Adobe CQ 5.6.1 Publish instance
16:57:30 +#
16:57:30 +# chkconfig: - 20 80
16:57:30 +# description: Adobe CQ is a Java-based web content management system
16:57:30 +
16:57:30 +### BEGIN INIT INFO
16:57:30 +# Provides: cq56-publish
16:57:30 +# Required-Start: $local_fs $network
16:57:30 +# Required-Stop: $local_fs $network
16:57:30 +# Short-Description: start and stop Adobe CQ 5.6.1 Publish
16:57:30 +# Description: Adobe CQ is a Java-based web content management system
16:57:30 +### END INIT INFO
16:57:30 +
16:57:30 +# Please make sure that the following file exists: /opt/cq/publish/crx-quickstart/conf/cq56-publish.conf
16:57:30 +
16:57:30 +PROG=cq56-publish
16:57:30 +CQ_CONF_FILE=/opt/cq/publish/crx-quickstart/conf/cq56-publish.conf
16:57:30 +
16:57:30 +# -----------------------------------------------------------------------------
16:57:30 +# do not configure below this point
16:57:30 +# -----------------------------------------------------------------------------
16:57:30 +
16:57:30 +# Source function library
16:57:30 +. /etc/rc.d/init.d/functions
16:57:30 +
16:57:30 +# Soruce CQ configuration file
16:57:30 +[ -e $CQ_CONF_FILE ] && . $CQ_CONF_FILE
16:57:30 +
16:57:30 +# Add JAVA_HOME to the PATH variable if
16:57:30
16:57:30 # /tmp/verifier/suites/serverspec/publish_spec.rb:98:in `block (2 levels) in <top (required)>'
16:57:30
16:57:30 Finished in 0.58629 seconds (files took 0.35047 seconds to load)
16:57:30 54 examples, 1 failure
16:57:30
16:57:30 Failed examples:
16:57:30
16:57:30 rspec /tmp/verifier/suites/serverspec/publish_spec.rb:96 # CQ init script contains KILL_DELAY line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment