Skip to content

Commit

Permalink
All tests now run in vagrant
Browse files Browse the repository at this point in the history
  • Loading branch information
neilhwatson committed Apr 4, 2017
1 parent 68b309b commit 312c618
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 36 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ https://github.com/neilhwatson/evolve_cfengine_freelib

## Version notice

The master branch is for CFEngine 3.7. See other branches of this repo for
CFEngine 3.6.
A Branch for each version. Master is the latest bleeding edge.

## License

Expand Down Expand Up @@ -68,7 +67,7 @@ in docs for more information.

## Requirements

1. Cfengine Core 3.7.0 or higher. There are older 3.6, 3.5, and 3.4 branches too.
1. Cfengine Core 3.10.0 or higher. There are older 3.10, 3.6, 3.5, and 3.4 branches too.
1. The Cfengine standard library.
1. Perl of any version and no special modules (only when using with Delta Reporting).

Expand Down
10 changes: 5 additions & 5 deletions src/masterfiles/lib/EFL/evolve_freelib.cf
Original file line number Diff line number Diff line change
Expand Up @@ -953,10 +953,10 @@ bundle agent efl_service_recurse ( ref )
"${d[${i}][config_dir]}" -> { "${d[${i}][promisee]}" }
comment => "Perms for destination files",
handle => "efl_service_recurse_files_perms",
if => "${d[${i}][class]}",
if => "${d[${i}][class]}",
classes => efl_rkn( "${d[${i}][config_dir]}",
"efl_service_recurse_perms" ),
action => efl_delta_reporting( "efl_service_recurse_perms",
"efl_service_recurse_files_perms" ),
action => efl_delta_reporting( "efl_service_recurse_files_perms",
"${d[${i}][config_dir]}", "${d[${i}][promisee]}", "1"
),
depth_search => recurse( "inf" ),
Expand All @@ -966,7 +966,7 @@ bundle agent efl_service_recurse ( ref )
"${d[${i}][process_regex]}" -> { "${d[${i}][promisee]}" }
comment => "Promise process is running",
handle => "efl_service_recurse_processes_proc",
classes => efl_rkn( "${d[${i}][process]}", "efl_service_recurse_processes_proc" ),
classes => efl_rkn( "${d[${i}][process_regex]}", "efl_service_recurse_processes_proc" ),
action => efl_delta_reporting( "efl_service_recurse_processes_proc", "${d[${i}][process]}", "${d[${i}][promisee]}", "1" ),
process_select => by_command( "${d[${i}][process_regex]}" ),
if => "${d[${i}][class]}",
Expand All @@ -980,7 +980,7 @@ bundle agent efl_service_recurse ( ref )
action => efl_delta_reporting( "efl_service_recurse_commands_restart", "${d[${i}][restart_cmd]}", "${d[${i}][promisee]}", "1" ),
contain => in_shell_and_silent,
if => or(
canonify( "efl_service_recurse_command_${d[${i}][restart_cmd]}" );
canonify( "efl_service_recurse_command_${d[${i}][restart_cmd]}" ),
canonify( "${d[${i}][config_dir]}_handle_efl_service_recurse_copy_repaired" )
);
}
Expand Down
3 changes: 1 addition & 2 deletions t/efl_copy_files.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use File::Copy;
use Carp;

# If you change this dir you must also change efl_data/efl_copy_files.csv
my $version = '3.7';
my $recurse_copy_dir = '/tmp/efl_test/efl_copy_files_recurse';
my $single_copy_dir = '/tmp/efl_test/efl_copy_files_single';
my $src_copy_dir = '/tmp/efl_test/efl_copy_files_src';
Expand Down Expand Up @@ -63,7 +62,7 @@ sub prep_source_files {

# Copies files to src dir for testing
for my $next_file ( @src_files ) {
copy( "test/masterfiles/lib/$version/EFL/$next_file" , "$dir/" )
copy( "test/masterfiles/lib/EFL/$next_file" , "$dir/" )
or croak "Cannot copy source file $next_file $!";
}
}
Expand Down
16 changes: 14 additions & 2 deletions t/efl_delete_files.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ my $test_dir = '/tmp/efl_test/efl_delete_files';
my $start_dir = getcwd();

my @data_formats = qw/ csv json /;
my $number_of_tests = scalar @data_formats * 2;
my $number_of_tests = 6;

# Start clean
remove_tree( $test_dir );

for my $next_format ( @data_formats ){

Expand All @@ -23,12 +26,20 @@ for my $next_format ( @data_formats ){

# Run cf-agent test policy
chdir 'test/masterfiles' or croak "Cannot cd to test/masterfiles $!";

my $cf_agent
= "cf-agent -D test_$next_format,efl_delete_files -Kf ./promises.cf";

# NOTE Needs two CFEngine runs to converge
ok(
WIFEXITED(
( system $cf_agent ) >> 8)
, "Run 1 efl_delete_files with $next_format"
);
ok(
WIFEXITED(
( system $cf_agent ) >> 8)
, "Run efl_delete_files with $next_format"
, "Run 2 efl_delete_files with $next_format"
);

# Test the results of cf-agent test policy
Expand Down Expand Up @@ -118,3 +129,4 @@ Test efl_delete_files
=back
=cut

1 change: 0 additions & 1 deletion t/efl_disable_service.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use Cwd;
use Carp;

my $start_dir = getcwd();
my $version = '3.7';
my $bundle = 'efl_disable_service';
my $service = 'efl_test_daemon';
my @tests = (
Expand Down
1 change: 0 additions & 1 deletion t/efl_edit_template.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use Carp;

my $start_dir = getcwd();

my $version = '3.7';
my $bundle = 'efl_edit_template';
my $test_config = "/tmp/efl_test/$bundle/config";

Expand Down
1 change: 0 additions & 1 deletion t/efl_enable_service.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use Cwd;
use Carp;

my $start_dir = getcwd();
my $version = '3.7';
my $bundle = 'efl_enable_service';
my $service = 'efl_test_daemon';
my @tests = (
Expand Down
11 changes: 8 additions & 3 deletions t/efl_rcs_pull.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ use Test::More;
use Carp;

my $start_dir = getcwd();
my $version = '3.7';
my $repo = '/tmp/efl_test/efl_rcs_pull/repo';
my $clone = '/tmp/efl_test/efl_rcs_pull/clone';
my $src = "masterfiles/lib/EFL";
my $file = "efl_update.cf";
my $bundle = 'efl_rcs_pull';
my %env = (
EMAIL => 'root@example.com',
GIT_COMMITTER_NAME => 'Test User',
);

my @tests = (
{
name => "$bundle clone fresh using csv data.",
Expand Down Expand Up @@ -75,7 +79,7 @@ sub make_repo {

Git::Repository->run( init => $repo )
or croak "Cannot init repo $repo $!";
my $git = Git::Repository->new( work_tree => $repo )
my $git = Git::Repository->new( work_tree => $repo, { env => \%env })
or croak "Cannot make new git object for $repo $!";

# Add file
Expand Down Expand Up @@ -122,7 +126,7 @@ sub update_clone {

croak "No Dlcass provided" unless $Dclass;

my $git = Git::Repository->new( work_tree => $repo )
my $git = Git::Repository->new( work_tree => $repo, { env => \%env })
or croak "Cannot create git object for $repo $!";

open( my $update_file, '>>', "$repo/$file")
Expand Down Expand Up @@ -169,3 +173,4 @@ sub run_agent_and_test {
Testing efl_rcs_pull
=cut

1 change: 0 additions & 1 deletion t/efl_service.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use Carp;

my $start_dir = getcwd();

my $version = '3.7';
my $test_config = '/tmp/efl_test/efl_service';
my $config_src = '/tmp/efl_test/templates/';
my $restart_flag = $test_config. '/restarted';
Expand Down
10 changes: 4 additions & 6 deletions t/efl_service_recurse.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ use Carp;

my $start_dir = getcwd();

my $version = '3.7';
my $test_config = '/tmp/efl_test/efl_service_recurse';
my $config_src = '/tmp/efl_test/efl_service_recurse_src/';
my $restart_flag = $test_config. '/restarted';
my @data_formats = qw/ csv json /;
my $number_of_tests = scalar @data_formats * 6;
my $daemon_proc
= qr{\A /bin/sh \s /tmp/efl_test/efl_test_daemon \z}mxs;
= qr{\A /bin/sh \s+ /tmp/efl_test/efl_test_daemon \Z}mxs;


# Prep copy source files
Expand Down Expand Up @@ -62,7 +61,6 @@ sub test_service_start {

# Ensure service is not running
killall( 'KILL', $daemon_proc );

run_cfagent({ format => $data_format });
test_end_state();

Expand Down Expand Up @@ -96,7 +94,7 @@ sub run_cfagent {
# Run cf-agent test policy
chdir 'test/masterfiles' or croak "Cannot cd to test/masterfiles $!";
my $cf_agent = "cf-agent -D test_$data_format,efl_service_recurse "
."-Kf ./promises.cf";
."-Kf ./promises.cf > agent.log";
ok(
WIFEXITED( ( system $cf_agent ) >> 8)
, "Run efl_service_recurse with $data_format"
Expand Down Expand Up @@ -127,7 +125,7 @@ sub prep_source_files {

# Copies files to src dir for testing
for my $next_file ( @src_files ) {
copy( "test/masterfiles/lib/$version/EFL/$next_file" , "$dir/" )
copy( "test/masterfiles/lib/EFL/$next_file" , "$dir/" )
or croak "Cannot copy source file $next_file $!";
}

Expand All @@ -141,4 +139,4 @@ sub prep_source_files {
Test efl_service_recurse bundle
=cut
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
ettin
oort
frodo
altair01
altair02
vega
polaris01
server1
server2
4 changes: 2 additions & 2 deletions test/masterfiles/efl_data/efl_class_hostname2.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[
{
"class_to_set" : "018_test_class_01",
"hostname" : [ "vega", "altair01", "altair02", "ettin", "oort", "frodo" ],
"hostname" : [ "server1", "server2" ],
"promisee" : "efl development"
},
{
"class_to_set" : "018_test_class_02",
"hostname" : [ "vega", "altair01", "altair02", "ettin", "oort", "frodo" ],
"hostname" : [ "server1", "server2" ],
"promisee" : "efl development"
},
{
Expand Down
4 changes: 2 additions & 2 deletions test/masterfiles/efl_data/efl_class_hostrange.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
"class_to_set" : "hostrange_class_01",
"promisee" : "efl development",
"hostname" : "altair",
"host_range" : "01-99"
"hostname" : "server",
"host_range" : "1-99"
},
{
"class_to_set" : "hostrange_class_02",
Expand Down
7 changes: 7 additions & 0 deletions vagrant/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
### Intro

Vagrant files for EFL build testing.

### How to

1. vargant up
1. To add more host types edit the vagrant file.

0 comments on commit 312c618

Please sign in to comment.