-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more tests for classes/conditionals/virtual resources.
- Loading branch information
Dan Bode
committed
Jul 9, 2010
1 parent
56968c5
commit ab69044
Showing
23 changed files
with
223 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find spec -mindepth 1 \( -type f -and -not -name '*.swp' \) -print0 | xargs -0 ls -t | head -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
cd ~/puppet/lib | ||
BIN=../bin | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find spec -mindepth 1 \( -type f -and -not -name '*.swp' \) -print0 | xargs -0 ls -t | head -1 | bash |
Empty file modified
0
spec/apply/classes/should_allow_param_class_default_override_spec.sh
100644 → 100755
Empty file.
Empty file.
Empty file modified
0
spec/apply/classes/should_allow_param_class_post_inclusion_spec.sh
100644 → 100755
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
set -e | ||
# | ||
# we are testing that resources declared in a class | ||
# can be applied with an include statement | ||
. local_setup.sh | ||
OUTFILE=/tmp/class_param_use-$$ | ||
$BIN/puppet apply <<PP | tee $OUTFILE | ||
class parent { | ||
notify { 'msg': | ||
message => parent, | ||
} | ||
} | ||
class child inherits parent { | ||
Notify['msg'] {message => 'child'} | ||
} | ||
include parent | ||
include child | ||
PP | ||
grep "defined 'message' as 'child'" $OUTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set -e | ||
# | ||
# we are testing that resources declared in a class | ||
# can be applied with an include statement | ||
. local_setup.sh | ||
OUTFILE=/tmp/class_undef_override_out-$$ | ||
echo 'hello world!' > /tmp/class_undef_override_test-$$ | ||
$BIN/puppet apply <<PP | tee $OUTFILE | ||
class parent { | ||
file { 'test': | ||
path => '/tmp/class_undef_file-$$', | ||
source => '/tmp/class_undef_override_test-$$', | ||
} | ||
} | ||
class child inherits parent { | ||
File['test'] { | ||
source => undef, | ||
content => 'hello new world!', | ||
} | ||
} | ||
include parent | ||
include child | ||
PP | ||
grep "hello new world" /tmp/class_undef_file-$$ |
Empty file modified
0
spec/apply/classes/should_include_resources_from_class_spec.sh
100644 → 100755
Empty file.
Empty file modified
0
spec/apply/classes/should_not_auto_include_resources_from_class_spec.sh
100644 → 100755
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# | ||
# ensure that undefined variables evaluate as false | ||
# | ||
. local_setup.sh | ||
|
||
$BIN/puppet apply <<PP | tee $OUTFILE | ||
if \$undef_var { | ||
} else { | ||
notice('undef') | ||
} | ||
PP | ||
grep 'undef' $OUTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# | ||
# test that false evaluates to false | ||
# | ||
source local_setup.sh | ||
|
||
$BIN/puppet <<PP | tee $OUTFILE | ||
if false { | ||
} else { | ||
notice('false') | ||
} | ||
PP | ||
grep 'false' $OUTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
spec/apply/conditionals/should_evaluate_strings_true_spec.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# | ||
# test that the string 'false' evaluates to true | ||
# | ||
source local_setup.sh | ||
|
||
$BIN/puppet <<PP | tee $OUTFILE | ||
if 'false' { | ||
notice('true') | ||
} else { | ||
notice('false') | ||
} | ||
PP | ||
grep 'true' $OUTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
source local_setup.sh | ||
$BIN/puppet apply <<PP | tee $OUTFILE | ||
if '' { | ||
} else { | ||
notice('empty') | ||
} | ||
PP | ||
grep empty $OUTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
# | ||
# | ||
# | ||
# | ||
set -e | ||
set -u | ||
|
||
. local_setup.sh | ||
|
||
HOSTFILE=/tmp/hosts-$$ | ||
# precondition: | ||
# /tmp/hosts-$$ should not exist | ||
if [ -e $HOSTFILE ]; then | ||
rm $HOSTFILE | ||
fi | ||
|
||
$BIN/puppet apply <<PP | ||
@host { 'test$$1': | ||
ip=>'127.0.0.2', | ||
target=>'$HOSTFILE', | ||
host_aliases => ['one', 'two', 'three'], | ||
ensure=>present, | ||
} | ||
@host { 'test$$2': | ||
ip=>'127.0.0.3', | ||
target=>'$HOSTFILE', | ||
host_aliases => 'two', | ||
ensure=>present, | ||
} | ||
Host<| host_aliases=='two' and ip=='127.0.0.3' |> | ||
PP | ||
grep test$$2 $HOSTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# | ||
# test that realize function takes a list. | ||
# | ||
set -e | ||
set -u | ||
|
||
. local_setup.sh | ||
|
||
HOSTFILE=/tmp/hosts-$$ | ||
# precondition: | ||
# /tmp/hosts-$$ should not exist | ||
if [ -e $HOSTFILE ]; then | ||
rm $HOSTFILE | ||
fi | ||
|
||
# puppet code | ||
$BIN/puppet apply <<PP | ||
@host{'test$$1': ip=>'127.0.0.2', target=>'$HOSTFILE', ensure=>present} | ||
@host{'test$$2': ip=>'127.0.0.2', target=>'$HOSTFILE', ensure=>present} | ||
realize(Host['test$$1'], Host['test$$2']) | ||
PP | ||
# validate - validate that our hostifle contains more than one line that matches test$$ | ||
[ $(grep test$$ $HOSTFILE | wc -l) == 2 ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
set -e | ||
|
||
. local_setup.sh | ||
|
||
HOSTFILE=/tmp/hosts-$$ | ||
# precondition: | ||
# /tmp/hosts-$$ should not exist | ||
if [ -e $HOSTFILE ]; then | ||
rm $HOSTFILE | ||
fi | ||
|
||
$BIN/puppet apply <<PP | ||
@host { 'test$$': | ||
ip=>'127.0.0.2', | ||
target=>'$HOSTFILE', | ||
host_aliases => ['one', 'two', 'three'], | ||
ensure=>present, | ||
} | ||
Host<| host_aliases=='two' |> | ||
PP | ||
grep test$$ $HOSTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
set -e | ||
|
||
. local_setup.sh | ||
|
||
HOSTFILE=/tmp/hosts-$$ | ||
# precondition: | ||
# /tmp/hosts-$$ should not exist | ||
if [ -e $HOSTFILE ]; then | ||
rm $HOSTFILE | ||
fi | ||
|
||
$BIN/puppet apply <<PP | ||
@host { 'test$$': | ||
ip=>'127.0.0.2', | ||
target=>'$HOSTFILE', | ||
host_aliases => 'alias', | ||
ensure=>present, | ||
} | ||
Host<| ip=='127.0.0.2' |> | ||
PP | ||
grep test$$ $HOSTFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
set -e | ||
|
||
. local_setup.sh | ||
|
||
HOSTFILE=/tmp/hosts-$$ | ||
# precondition: | ||
# /tmp/hosts-$$ should not exist | ||
if [ -e $HOSTFILE ]; then | ||
rm $HOSTFILE | ||
fi | ||
|
||
$BIN/puppet apply <<PP | ||
@host{'test$$': ip=>'127.0.0.2', target=>'$HOSTFILE', ensure=>present} | ||
realize(Host['test$$']) | ||
PP | ||
grep test$$ $HOSTFILE |