Permalink
Browse files

Stole jes5199's puppet-spec and mangled it for my own purposes

* http://github.com/jes5199/puppet_spec
* created should_change_state_to_up_spec
* created should_change_state_to_down_spec

Both tests returned true because ralsh is not affected by bug #2211

Signed-off-by: William Van Hevelingen <wvan13@gmail.com>
  • Loading branch information...
1 parent 1703853 commit 1069cadbfa74d267471cfb96e430b8202c3e437c @blkperl blkperl committed Aug 3, 2010
View
@@ -0,0 +1 @@
+local_setup.sh
View
@@ -0,0 +1,4 @@
+.PHONY: test
+.DEFAULT: test
+test:
+ @bash puppet_spec.sh
View
@@ -0,0 +1 @@
+find spec -mindepth 1 \( -type f -and -not -name '*.swp' \) -print0 | xargs -0 ls -t | head -1
@@ -0,0 +1,2 @@
+cd ~/puppet/lib
+BIN=../bin
View
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+TEST_DIR=$1
+: ${TEST_DIR:='./spec'}
+
+if ! [ -f local_setup.sh ] ; then
+ echo '
+You must create a local_setup.sh so we know where to find the puppet libs.
+
+Example:
+'
+ cat local_setup.example.sh
+ exit 2
+fi
+
+let FAILURES=0
+let TOTAL=0
+let PENDING=0
+let SKIPPED=0
+
+FAIL_LOG=/tmp/$$.failures.txt
+touch $FAIL_LOG
+
+for SPEC in `find $TEST_DIR -name '*_spec.sh' ` ; do
+ if ! [ -x $SPEC ] ; then
+ echo -n p
+ let "PENDING+=1"
+ continue
+ fi
+ if $SPEC >& /dev/null ; then
+ echo -n .
+ else
+ let TEST_ERROR=$?
+ if [ $TEST_ERROR -eq 11 ] ; then
+ echo -n '~'
+ let "SKIPPED+=1"
+ else
+ echo $SPEC >> $FAIL_LOG
+ let "FAILURES+=1"
+ echo -n F
+ fi
+ fi
+ let "TOTAL+=1"
+done
+echo
+echo -n "$TOTAL tests, $FAILURES failures"
+if [ "$PENDING" -ne 0 ] ; then
+ echo -n ", $PENDING pending"
+fi
+if [ "$SKIPPED" -ne 0 ] ; then
+ echo -n ", $SKIPPED skipped"
+fi
+echo
+
+cat -n $FAIL_LOG
+
+[ $FAILURES -eq 0 ]
View
@@ -0,0 +1 @@
+find spec -mindepth 1 \( -type f -and -not -name '*.swp' \) -print0 | xargs -0 ls -t | head -1 | bash
@@ -0,0 +1,93 @@
+#!/bin/bash
+. spec/util.sh
+
+function driver_standalone {
+ function execute_manifest {
+ mkdir -p /tmp/puppet-$$-standalone/manifests
+ cat | $BIN/puppet apply --confdir /tmp/puppet-$$-standalone --debug --manifestdir /tmp/puppet-$$-standalone/manifests --modulepath /tmp/puppet-$$-standalone/modules "$@"
+ }
+
+ function puppet_conf {
+ cat > /tmp/puppet-$$/puppet.conf
+ }
+
+ function manifest_file {
+ mkdir -p /tmp/puppet-$$-standalone/manifests
+ cat > /tmp/puppet-$$-standalone/manifests/$1
+ }
+
+ function module_file {
+ mkdir -p `dirname /tmp/puppet-$$-standalone/modules/$1`
+ cat > /tmp/puppet-$$-standalone/modules/$1
+ }
+}
+
+function driver_standalone_using_files {
+ driver_standalone # sort of like inherits
+
+ function execute_manifest {
+ cat > /tmp/manifest-$$.pp
+ mkdir -p /tmp/puppet-$$-standalone/manifests
+ $BIN/puppet apply --confdir /tmp/puppet-$$-standalone --debug --manifestdir /tmp/puppet-$$-standalone/manifests --modulepath /tmp/puppet-$$-standalone/modules "$@" /tmp/manifest-$$.pp
+ }
+
+}
+
+function driver_master_and_agent_locally {
+ mkdir -p /tmp/puppet-$$-master/manifests/
+ mkdir -p /tmp/puppet-$$-agent
+
+ function execute_manifest {
+ start_puppet_master
+ cat > /tmp/puppet-$$-master/manifests/site.pp
+ start_puppet_agent "$@"
+ stop_puppet_master
+ }
+
+ function manifest_file {
+ mkdir -p /tmp/puppet-$$-master/manifests
+ cat > /tmp/puppet-$$-master/manifests/$1
+ }
+
+ function module_file {
+ mkdir -p `dirname /tmp/puppet-$$-master/modules/$1`
+ cat > /tmp/puppet-$$-master/modules/$1
+ }
+
+ function puppet_conf {
+ cat | tee /tmp/puppet-$$-master/puppet.conf > /tmp/puppet-$$-agent/puppet.conf
+ }
+
+ function module_file {
+ mkdir -p `dirname /tmp/puppet-$$-master/modules/$1`
+ cat > /tmp/puppet-$$-master/modules/$1
+ }
+}
+
+function driver_master_and_agent_locally_using_old_executables {
+ driver_master_and_agent_locally # sort of like inherits
+
+ function execute_manifest {
+ start_puppetmasterd
+ cat > /tmp/puppet-$$-master/manifests/site.pp
+ start_puppetd "$@"
+ stop_puppetmasterd
+ }
+}
+
+
+function env_driver {
+ if [ -z "${PUPPET_ACCEPTANCE_DRIVER:-}" ] ; then
+ PUPPET_ACCEPTANCE_DRIVER=standalone
+ fi
+ driver_$PUPPET_ACCEPTANCE_DRIVER
+}
+
+function use_driver {
+ if [ -z "$PUPPET_ACCEPTANCE_DRIVER" ] || [ "$PUPPET_ACCEPTANCE_DRIVER" = "$1" ] ; then
+ driver_$1
+ else
+ NOT_APPLICABLE
+ fi
+}
+
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# checks that puppet resource can change device eth0 to down.
+
+set -e
+set -u
+
+. local_setup.sh
+
+# Set eth0 state up (if its not already)
+echo 'ip link set eth0 up'
+
+# Puppet will set eth0 down
+$BIN/puppet resource network_interface eth0 state="down"
+
+# Test to see if eth0 is down
+echo 'ip link show dev eth0 | grep DOWN'
+
+
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# checks that puppet resource can change device eth0 to up.
+# this will fail til Bug #2211 is fixed
+set -e
+set -u
+
+. local_setup.sh
+
+# Set eth0 state down (if its not already)
+echo 'ip link set eth0 down'
+
+# Puppet will set eth0 up
+$BIN/puppet resource network_interface eth0 state="up"
+
+# Test to see if eth0 is up
+echo 'ip link show dev eth0 | grep UP'
+
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+. spec/drivers.sh
+env_driver
+. local_setup.sh
View
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+function start_puppet_agent {
+ MASTER_PORT=18140
+ $BIN/puppet agent --vardir /tmp/puppet-$$-agent-var --confdir /tmp/puppet-$$-agent --rundir /tmp/puppet-$$-agent \
+ --no-daemonize --onetime --server localhost --debug --masterport $MASTER_PORT "$@"
+}
+
+function start_puppet_master {
+ MASTER_PORT=18140
+ mkdir -p /tmp/puppet-$$-master/manifests/
+ $BIN/puppet master --vardir /tmp/puppet-$$-master-var --confdir /tmp/puppet-$$-master --rundir /tmp/puppet-$$-master \
+ --no-daemonize --autosign=true --certname=localhost --masterport $MASTER_PORT "$@" &
+ MASTER_PID=$!
+
+ for I in `seq 0 10` ; do
+ if lsof -i -n -P | grep '\*:'$MASTER_PORT | grep $MASTER_PID > /dev/null ; then
+ break
+ else
+ sleep 1
+ fi
+ done
+
+}
+
+function stop_puppet_master {
+ kill $MASTER_PID
+}
+
+
+
+
+function start_puppetd {
+ MASTER_PORT=18140
+ $BIN/../sbin/puppetd --vardir /tmp/puppet-$$-agent-var --confdir /tmp/puppet-$$-agent --rundir /tmp/puppet-$$-agent \
+ --no-daemonize --onetime --server localhost --debug --masterport $MASTER_PORT "$@"
+}
+
+function start_puppetmasterd {
+ MASTER_PORT=18140
+ mkdir -p /tmp/puppet-$$-master/manifests/
+ $BIN/../sbin/puppetmasterd --vardir /tmp/puppet-$$-master-var --confdir /tmp/puppet-$$-master --rundir /tmp/puppet-$$-master \
+ --no-daemonize --autosign=true --certname=localhost --masterport $MASTER_PORT "$@" &
+ MASTER_PID=$!
+
+ for I in `seq 0 10` ; do
+ if lsof -i -n -P | grep '\*:'$MASTER_PORT | grep $MASTER_PID > /dev/null ; then
+ break
+ else
+ sleep 1
+ fi
+ done
+
+}
+
+function stop_puppetmasterd {
+ kill $MASTER_PID
+}
+
+function NOT_APPLICABLE {
+ exit 11
+}

0 comments on commit 1069cad

Please sign in to comment.