From 9507d838668846666d2c790a0a1e6e51eb8670de Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Fri, 4 Jan 2008 16:50:15 +0000 Subject: more refactoring (not limited to attribute handling) * completed separation of attributes and standard (column) values * improved tests a lot That work is still not finished, so expect things to fail horribly. git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1443 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/t/01-basics.t | 3 + config-db/t/10-vendor-os.t | 6 + config-db/t/11-export.t | 6 + config-db/t/12-system.t | 215 ++++++++- config-db/t/13-client.t | 179 ++++++- config-db/t/14-group.t | 182 +++++++- config-db/t/15-global_info.t | 5 +- config-db/t/20-client_system_ref.t | 7 +- config-db/t/21-group_system_ref.t | 7 +- config-db/t/22-group_client_ref.t | 7 +- config-db/t/25-attributes.t | 929 +++++++++++++++++++------------------ config-db/t/29-transaction.t | 3 + 12 files changed, 1042 insertions(+), 507 deletions(-) (limited to 'config-db/t') diff --git a/config-db/t/01-basics.t b/config-db/t/01-basics.t index fdc7a052..903783c4 100644 --- a/config-db/t/01-basics.t +++ b/config-db/t/01-basics.t @@ -5,6 +5,9 @@ use lib '/opt/openslx/lib'; # basic stuff use_ok(OpenSLX::ConfigDB); +use strict; +use warnings; + # connecting and disconnecting ok(my $configDB = OpenSLX::ConfigDB->new, 'can create object'); isa_ok($configDB, 'OpenSLX::ConfigDB'); diff --git a/config-db/t/10-vendor-os.t b/config-db/t/10-vendor-os.t index b0754be7..04aa4f2e 100644 --- a/config-db/t/10-vendor-os.t +++ b/config-db/t/10-vendor-os.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -176,6 +179,9 @@ ok( is($vendorOS1->{id}, 1, 'really got vendor-OS number 1'); is($vendorOS1->{name}, q{VOS-'1'}, q{really got vendor-OS named "VOS-'1'"}); +# changing nothing at all should succeed +ok($configDB->changeVendorOS(1), 'changing nothing at all in vendor-OS 1'); + # changing a non-existing column should fail ok( ! eval { $configDB->changeVendorOS(1, { xname => "xx" }) }, diff --git a/config-db/t/11-export.t b/config-db/t/11-export.t index 96fad00b..0cdc688c 100644 --- a/config-db/t/11-export.t +++ b/config-db/t/11-export.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -223,6 +226,9 @@ ok( is($export1->{id}, 1, 'really got export number 1'); is($export1->{name}, q{EXP-'1'}, q{really got export named "EXP-'1'"}); +# changing nothing at all should succeed +ok($configDB->changeExport(1), 'changing nothing at all in export 1'); + # changing a non-existing column should fail ok( ! eval { $configDB->changeExport(1, { xname => "xx" }) }, diff --git a/config-db/t/12-system.t b/config-db/t/12-system.t index ee908dba..7a3e5e1e 100644 --- a/config-db/t/12-system.t +++ b/config-db/t/12-system.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -35,6 +38,11 @@ my $inSystem1 = { 'name' => 'sys-1', 'export_id' => 1, 'comment' => '', + 'attrs' => { + 'ramfs_fsmods' => 'squashfs', + 'ramfs_nicmods' => 'e1000 forcedeth r8169', + 'start_sshd' => 'yes', + }, }; is( my $system1ID = $configDB->addSystem($inSystem1), 1, @@ -55,10 +63,43 @@ my $fullSystem = { 'label' => 'BlingBling System - really kuul!', 'kernel_params' => 'debug=3 console=ttyS1', 'hidden' => '1', - 'attr_ramfs_nicmods' => 'e1000 forcedeth', - 'attr_ramfs_fsmods' => 'squashfs', - 'attr_ramfs_miscmods' => 'tpm', - 'attr_ramfs_screen' => '1024x768', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'ramfs_fsmods' => 'l', + 'ramfs_miscmods' => 'm', + 'ramfs_nicmods' => 'n', + 'ramfs_screen' => 'o', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( my ($system2ID, $system3ID) = $configDB->addSystem([ @@ -79,39 +120,72 @@ is($system3->{comment}, 'nuff said', 'system 3 - comment is($system3->{label}, 'BlingBling System - really kuul!', 'system 3 - label'); is($system3->{kernel_params}, 'debug=3 console=ttyS1', 'system 3 - kernel_params'); is($system3->{hidden}, '1', 'system 3 - hidden'); -is($system3->{attr_ramfs_nicmods}, 'e1000 forcedeth', 'system 3 - attr_ramfs_nicmods'); -is($system3->{attr_ramfs_fsmods}, 'squashfs', 'system 3 - attr_ramfs_fsmods'); -is($system3->{attr_ramfs_miscmods}, 'tpm', 'system 3 - attr_ramfs_miscmods'); -is($system3->{attr_ramfs_screen}, '1024x768', 'system 3 - attr_ramfs_screen'); +is($system3->{attrs}->{automnt_dir}, 'a', 'system 3 - attr automnt_dir'); +is($system3->{attrs}->{automnt_src}, 'b', 'system 3 - attr automnt_src'); +is($system3->{attrs}->{country}, 'c', 'system 3 - attr country'); +is($system3->{attrs}->{dm_allow_shutdown}, 'd', 'system 3 - attr dm_allow_shutdown'); +is($system3->{attrs}->{hw_graphic}, 'e', 'system 3 - attr hw_graphic'); +is($system3->{attrs}->{hw_monitor}, 'f', 'system 3 - attr hw_monitor'); +is($system3->{attrs}->{hw_mouse}, 'g', 'system 3 - attr hw_mouse'); +is($system3->{attrs}->{late_dm}, 'h', 'system 3 - attr late_dm'); +is($system3->{attrs}->{netbios_workgroup}, 'i', 'system 3 - attr netbios_workgroup'); +is($system3->{attrs}->{nis_domain}, 'j', 'system 3 - attr nis_domain'); +is($system3->{attrs}->{nis_servers}, 'k', 'system 3 - attr nis_servers'); +is($system3->{attrs}->{ramfs_fsmods}, 'l', 'system 3 - attr ramfs_fsmods'); +is($system3->{attrs}->{ramfs_miscmods}, 'm', 'system 3 - attr ramfs_miscmods'); +is($system3->{attrs}->{ramfs_nicmods}, 'n', 'system 3 - attr ramfs_nicmods'); +is($system3->{attrs}->{ramfs_screen}, 'o', 'system 3 - attr ramfs_screen'); +is($system3->{attrs}->{sane_scanner}, 'p', 'system 3 - attr sane_scanner'); +is($system3->{attrs}->{scratch}, 'q', 'system 3 - attr scratch'); +is($system3->{attrs}->{slxgrp}, 'r', 'system 3 - attr slxgrp'); +is($system3->{attrs}->{start_alsasound}, 's', 'system 3 - attr start_alsasound'); +is($system3->{attrs}->{start_atd}, 't', 'system 3 - attr start_atd'); +is($system3->{attrs}->{start_cron}, 'u', 'system 3 - attr start_cron'); +is($system3->{attrs}->{start_dreshal}, 'v', 'system 3 - attr start_dreshal'); +is($system3->{attrs}->{start_ntp}, 'w', 'system 3 - attr start_ftp'); +is($system3->{attrs}->{start_nfsv4}, 'x', 'system 3 - attr start_nfsv4'); +is($system3->{attrs}->{start_printer}, 'y', 'system 3 - attr start_printer'); +is($system3->{attrs}->{start_samba}, 'z', 'system 3 - attr start_samba'); +is($system3->{attrs}->{start_snmp}, 'A', 'system 3 - attr start_snmp'); +is($system3->{attrs}->{start_sshd}, 'B', 'system 3 - attr start_sshd'); +is($system3->{attrs}->{start_syslog}, 'C', 'system 3 - attr start_syslog'); +is($system3->{attrs}->{start_x}, 'D', 'system 3 - attr start_x'); +is($system3->{attrs}->{start_xdmcp}, 'E', 'system 3 - attr start_xdmcp'); +is($system3->{attrs}->{tex_enable}, 'F', 'system 3 - attr tex_enable'); +is($system3->{attrs}->{timezone}, 'G', 'system 3 - attr timezone'); +is($system3->{attrs}->{tvout}, 'H', 'system 3 - attr tvout'); +is($system3->{attrs}->{vmware}, 'I', 'system 3 - attr vmware'); +is(keys %{$system3->{attrs}}, 35, 'system 3 - attribute count'); # fetch system 2 by a filter on id and check all values ok( my $system2 = $configDB->fetchSystemByFilter({ id => 2 }), 'fetch system 2 by filter on id' ); -is($system2->{id}, 2, 'system 2 - id'); -is($system2->{name}, 'sys-2.0', 'system 2 - name'); -is($system2->{kernel}, 'vmlinuz', 'system 2 - kernel'); -is($system2->{export_id}, '1', 'system 2 - export_id'); -is($system2->{comment}, undef, 'system 2 - comment'); +is($system2->{id}, 2, 'system 2 - id'); +is($system2->{name}, 'sys-2.0', 'system 2 - name'); +is($system2->{kernel}, 'vmlinuz', 'system 2 - kernel'); +is($system2->{export_id}, '1', 'system 2 - export_id'); +is($system2->{comment}, undef, 'system 2 - comment'); +is(keys %{$system2->{attrs}}, 0, 'system 2 - attribute count'); # fetch system 1 by filter on name and check all values ok( my $system1 = $configDB->fetchSystemByFilter({ name => 'sys-1' }), 'fetch system 1 by filter on name' ); -is($system1->{id}, 1, 'system 1 - id'); -is($system1->{name}, 'sys-1', 'system 1 - name'); -is($system1->{export_id}, '1', 'system 1 - export_id'); -is($system1->{kernel}, 'vmlinuz', 'system 1 - kernel'); -is($system1->{comment}, '', 'system 1 - comment'); -is($system1->{label}, 'sys-1', 'system 1 - label'); -is($system1->{kernel_params}, undef, 'system 1 - kernel_params'); -is($system1->{hidden}, undef, 'system 1 - hidden'); -is($system1->{attr_ramfs_nicmods}, undef, 'system 1 - attr_ramfs_nicmods'); -is($system1->{attr_ramfs_fsmods}, undef, 'system 1 - attr_ramfs_fsmods'); -is($system1->{attr_ramfs_miscmods}, undef, 'system 1 - attr_ramfs_miscmods'); -is($system1->{attr_ramfs_screen}, undef, 'system 1 - attr_ramfs_screen'); +is($system1->{id}, 1, 'system 1 - id'); +is($system1->{name}, 'sys-1', 'system 1 - name'); +is($system1->{export_id}, '1', 'system 1 - export_id'); +is($system1->{kernel}, 'vmlinuz', 'system 1 - kernel'); +is($system1->{comment}, '', 'system 1 - comment'); +is($system1->{label}, 'sys-1', 'system 1 - label'); +is($system1->{kernel_params}, undef, 'system 1 - kernel_params'); +is($system1->{hidden}, undef, 'system 1 - hidden'); +is(keys %{$system1->{attrs}}, 3, 'system 1 - attribute count'); +is($system1->{attrs}->{ramfs_fsmods}, 'squashfs', 'system 1 - attr ramfs_fsmods'); +is($system1->{attrs}->{ramfs_nicmods}, 'e1000 forcedeth r8169', 'system 1 - attr ramfs_nicmods'); +is($system1->{attrs}->{start_sshd}, 'yes', 'system 1 - attr start_sshd'); # fetch systems 3 & 1 by id ok( @@ -148,6 +222,17 @@ is(@systems1And2, 2, 'should have got 2 systems'); is($systems1And2[0]->{id}, 1, 'first id should be 1'); is($systems1And2[1]->{id}, 2, 'second id should be 2'); +# fetch systems 1 & 2 by filter on hidden being undef'd +ok( + @systems1And2 = $configDB->fetchSystemByFilter({ hidden => undef }), + 'fetch systems 1 & 2 by filter on hidden being undefined' +); +is(@systems1And2, 2, 'should have got 2 systems'); +# now sort by ID and check if we have really got 1 and 2 +@systems1And2 = sort { $a->{id} cmp $b->{id} } @systems1And2; +is($systems1And2[0]->{id}, 1, 'first id should be 1'); +is($systems1And2[1]->{id}, 2, 'second id should be 2'); + # try to fetch with multi-column filter ok( ($system2, $system3) @@ -169,6 +254,83 @@ is(@systems1And3, 2, 'should have got 2 systems'); is($systems1And3[0]->{id}, 1, 'first id should be 1'); is($systems1And3[1]->{id}, 3, 'second id should be 3'); +# filter systems by different attributes & values in combination +ok( + my @system1Only = $configDB->fetchSystemByFilter( {}, undef, { + ramfs_nicmods => 'e1000 forcedeth r8169' + } ), + 'fetch system 1 by filter on attribute ramfs_nicmods' +); + +is(@system1Only, 1, 'should have got 1 system'); +is($system1Only[0]->{id}, 1, 'first id should be 1'); + +ok( + @system1Only = $configDB->fetchSystemByFilter( undef, 'id', { + ramfs_nicmods => 'e1000 forcedeth r8169', + slxgrp => undef, + } ), + 'fetch system 1 by filter on attribute ramfs_nicmods' +); +is(@system1Only, 1, 'should have got 1 system'); +is($system1Only[0]->{id}, 1, 'first id should be 1'); + +ok( + @system1Only = $configDB->fetchSystemByFilter( { + export_id => 1, + hidden => undef, + }, 'id', { + ramfs_nicmods => 'e1000 forcedeth r8169', + slxgrp => undef, + } ), + 'fetch system 1 by multiple filter on values and attributes' +); +is(@system1Only, 1, 'should have got 1 system'); +is($system1Only[0]->{id}, 1, 'first id should be 1'); + +is( + $configDB->fetchSystemByFilter( { + export_id => 2, + }, 'id', { + ramfs_nicmods => 'e1000 forcedeth r8169', + slxgrp => undef, + } ), + undef, + 'mismatch system 1 by filter with incorrect value' +); +is( + $configDB->fetchSystemByFilter( { + export_id => 1, + }, 'id', { + ramfs_nicmods => 'xxxx', + slxgrp => undef, + } ), + undef, + 'mismatch system 1 by filter with incorrect attribute value' +); +is( + $configDB->fetchSystemByFilter( { + name => 'sys-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch system 1 by filter with attribute not being empty' +); + +# fetch systems 1 & 2 by filter on attribute start_samba not existing +ok( + @systems1And2 = $configDB->fetchSystemByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch systems 1 & 2 by filter on attribute start_samba not existing' +); +is(@systems1And2, 2, 'should have got 2 systems'); +# now sort by ID and check if we have really got 1 and 2 +@systems1And2 = sort { $a->{id} cmp $b->{id} } @systems1And2; +is($systems1And2[0]->{id}, 1, 'first id should be 1'); +is($systems1And2[1]->{id}, 2, 'second id should be 2'); + # try to fetch a couple of non-existing systems by id is( $configDB->fetchSystemByID(-1), undef, @@ -203,6 +365,9 @@ ok( is($system1->{id}, 1, 'really got system number 1'); is($system1->{name}, q{SYS-'1'}, q{really got system named "SYS-'1'"}); +# changing nothing at all should succeed +ok($configDB->changeSystem(1), 'changing nothing at all in system 1'); + # changing a non-existing column should fail ok( ! eval { $configDB->changeSystem(1, { xname => "xx" }) }, diff --git a/config-db/t/13-client.t b/config-db/t/13-client.t index 70ed569c..5848ba53 100644 --- a/config-db/t/13-client.t +++ b/config-db/t/13-client.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -35,6 +38,11 @@ my $inClient1 = { 'name' => 'cli-1', 'mac' => '01:02:03:04:05:01', 'comment' => '', + 'attrs' => { + 'slxgrp' => 'slxgrp', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + }, }; is( my $client1ID = $configDB->addClient($inClient1), 1, @@ -55,6 +63,39 @@ my $fullClient = { 'kernel_params' => 'debug=3 console=ttyS1', 'unbootable' => '0', 'boot_type' => 'pxe', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( my ($client2ID, $client3ID) = $configDB->addClient([ @@ -74,18 +115,51 @@ is($client3->{comment}, 'nuff said', 'client 3 - comment'); is($client3->{boot_type}, 'pxe', 'client 3 - boot_type'); is($client3->{kernel_params}, 'debug=3 console=ttyS1', 'client 3 - kernel_params'); is($client3->{unbootable}, '0', 'client 3 - unbootable'); +is($client3->{attrs}->{automnt_dir}, 'a', 'client 3 - attr automnt_dir'); +is($client3->{attrs}->{automnt_src}, 'b', 'client 3 - attr automnt_src'); +is($client3->{attrs}->{country}, 'c', 'client 3 - attr country'); +is($client3->{attrs}->{dm_allow_shutdown}, 'd', 'client 3 - attr dm_allow_shutdown'); +is($client3->{attrs}->{hw_graphic}, 'e', 'client 3 - attr hw_graphic'); +is($client3->{attrs}->{hw_monitor}, 'f', 'client 3 - attr hw_monitor'); +is($client3->{attrs}->{hw_mouse}, 'g', 'client 3 - attr hw_mouse'); +is($client3->{attrs}->{late_dm}, 'h', 'client 3 - attr late_dm'); +is($client3->{attrs}->{netbios_workgroup}, 'i', 'client 3 - attr netbios_workgroup'); +is($client3->{attrs}->{nis_domain}, 'j', 'client 3 - attr nis_domain'); +is($client3->{attrs}->{nis_servers}, 'k', 'client 3 - attr nis_servers'); +is($client3->{attrs}->{sane_scanner}, 'p', 'client 3 - attr sane_scanner'); +is($client3->{attrs}->{scratch}, 'q', 'client 3 - attr scratch'); +is($client3->{attrs}->{slxgrp}, 'r', 'client 3 - attr slxgrp'); +is($client3->{attrs}->{start_alsasound}, 's', 'client 3 - attr start_alsasound'); +is($client3->{attrs}->{start_atd}, 't', 'client 3 - attr start_atd'); +is($client3->{attrs}->{start_cron}, 'u', 'client 3 - attr start_cron'); +is($client3->{attrs}->{start_dreshal}, 'v', 'client 3 - attr start_dreshal'); +is($client3->{attrs}->{start_ntp}, 'w', 'client 3 - attr start_ftp'); +is($client3->{attrs}->{start_nfsv4}, 'x', 'client 3 - attr start_nfsv4'); +is($client3->{attrs}->{start_printer}, 'y', 'client 3 - attr start_printer'); +is($client3->{attrs}->{start_samba}, 'z', 'client 3 - attr start_samba'); +is($client3->{attrs}->{start_snmp}, 'A', 'client 3 - attr start_snmp'); +is($client3->{attrs}->{start_sshd}, 'B', 'client 3 - attr start_sshd'); +is($client3->{attrs}->{start_syslog}, 'C', 'client 3 - attr start_syslog'); +is($client3->{attrs}->{start_x}, 'D', 'client 3 - attr start_x'); +is($client3->{attrs}->{start_xdmcp}, 'E', 'client 3 - attr start_xdmcp'); +is($client3->{attrs}->{tex_enable}, 'F', 'client 3 - attr tex_enable'); +is($client3->{attrs}->{timezone}, 'G', 'client 3 - attr timezone'); +is($client3->{attrs}->{tvout}, 'H', 'client 3 - attr tvout'); +is($client3->{attrs}->{vmware}, 'I', 'client 3 - attr vmware'); +is(keys %{$client3->{attrs}}, 31, 'client 3 - attribute count'); # fetch client 2 by a filter on id and check all values ok( my $client2 = $configDB->fetchClientByFilter({ id => 2 }), 'fetch client 2 by filter on id' ); -is($client2->{id}, 2, 'client 2 - id'); -is($client2->{name}, 'cli-2.0', 'client 2 - name'); -is($client2->{unbootable}, '1', 'client 2 - unbootable'); -is($client2->{mac}, '01:02:03:04:05:02', 'client 2 - mac'); -is($client2->{comment}, undef, 'client 2 - comment'); -is($client2->{boot_type}, 'etherboot', 'client 2 - boot_type'); +is($client2->{id}, 2, 'client 2 - id'); +is($client2->{name}, 'cli-2.0', 'client 2 - name'); +is($client2->{unbootable}, '1', 'client 2 - unbootable'); +is($client2->{mac}, '01:02:03:04:05:02', 'client 2 - mac'); +is($client2->{comment}, undef, 'client 2 - comment'); +is($client2->{boot_type}, 'etherboot', 'client 2 - boot_type'); +is(keys %{$client2->{attrs}}, 0, 'client 2 - attribute count'); # fetch client 1 by filter on name and check all values ok( @@ -99,6 +173,10 @@ is($client1->{unbootable}, undef, 'client 1 - unbootable'); is($client1->{comment}, '', 'client 1 - comment'); is($client1->{boot_type}, 'pxe', 'client 1 - boot_type'); is($client1->{kernel_params}, undef, 'client 1 - kernel_params'); +is(keys %{$client1->{attrs}}, 3, 'client 1 - attribute count'); +is($client1->{attrs}->{slxgrp}, 'slxgrp', 'client 1 - attr slxgrp'); +is($client1->{attrs}->{start_snmp}, 'no', 'client 1 - attr start_snmp'); +is($client1->{attrs}->{start_sshd}, 'yes', 'client 1 - attr start_sshd'); # fetch clients 3 & 1 by id ok( @@ -144,6 +222,14 @@ ok( is($client1->{name}, 'cli-1', 'should have got cli-1'); is($client3, undef, 'should not get cli-nr-3'); +# fetch client 1 by filter on unbootable being undef'd +ok( + my @client1Only = $configDB->fetchClientByFilter({ unbootable => undef }), + 'fetch client 1 by filter on unbootable being undefined' +); +is(@client1Only, 1, 'should have got 1 client'); +is($client1Only[0]->{id}, 1, 'first id should be 1'); + # try to fetch multiple occurrences of the same client, combined with # some unknown IDs ok( @@ -156,6 +242,84 @@ is(@clients1And3, 2, 'should have got 2 clients'); is($clients1And3[0]->{id}, 1, 'first id should be 1'); is($clients1And3[1]->{id}, 3, 'second id should be 3'); +# filter clients by different attributes & values in combination +ok( + @client1Only = $configDB->fetchClientByFilter( {}, undef, { + start_snmp => 'no', + } ), + 'fetch client 1 by filter on attribute start_snmp' +); + +is(@client1Only, 1, 'should have got 1 client'); +is($client1Only[0]->{id}, 1, 'first id should be 1'); + +ok( + @client1Only = $configDB->fetchClientByFilter( undef, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch client 1 by filter on attribute start_snmp + non-existing attr' +); +is(@client1Only, 1, 'should have got 1 client'); +is($client1Only[0]->{id}, 1, 'first id should be 1'); + +ok( + @client1Only = $configDB->fetchClientByFilter( { + name => 'cli-1', + unbootable => undef, + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch client 1 by multiple filter on values and attributes' +); +is(@client1Only, 1, 'should have got 1 client'); +is($client1Only[0]->{id}, 1, 'first id should be 1'); + +is( + $configDB->fetchClientByFilter( { + comment => 'xxx', + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + undef, + 'mismatch client 1 by filter with incorrect value' +); +is( + $configDB->fetchClientByFilter( { + name => 'cli-1', + }, 'id', { + start_snmp => 'yes', + tex_enable => undef, + } ), + undef, + 'mismatch client 1 by filter with incorrect attribute value' +); +is( + $configDB->fetchClientByFilter( { + name => 'cli-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch client 1 by filter with attribute not being empty' +); + +# fetch clients 0, 1 & 2 by filter on attribute start_samba not existing +ok( + my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch clients 0,1 & 2 by filter on attribute start_samba not existing' +); +is(@clients01And2, 3, 'should have got 3 clients'); +# now sort by ID and check if we have really got 0, 1 and 2 +@clients01And2 = sort { $a->{id} cmp $b->{id} } @clients01And2; +is($clients01And2[0]->{id}, 0, 'first id should be 0'); +is($clients01And2[1]->{id}, 1, 'second id should be 1'); +is($clients01And2[2]->{id}, 2, 'third id should be 2'); + # try to fetch a couple of non-existing clients by id is( $configDB->fetchClientByID(-1), undef, @@ -190,6 +354,9 @@ ok( is($client1->{id}, 1, 'really got client number 1'); is($client1->{name}, q{CLI-'1'}, q{really got client named "CLI-'1'"}); +# changing nothing at all should succeed +ok($configDB->changeClient(1), 'changing nothing at all in client 1'); + # changing a non-existing column should fail ok( ! eval { $configDB->changeClient(1, { xname => "xx" }) }, diff --git a/config-db/t/14-group.t b/config-db/t/14-group.t index 70831a5e..59530257 100644 --- a/config-db/t/14-group.t +++ b/config-db/t/14-group.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -34,6 +37,11 @@ is( my $inGroup1 = { 'name' => 'grp-1', 'comment' => '', + 'attrs' => { + 'slxgrp' => 'slxgrp', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + }, }; is( my $group1ID = $configDB->addGroup($inGroup1), 1, @@ -49,6 +57,39 @@ my $fullGroup = { 'name' => 'grp-nr-3', 'priority' => 50, 'comment' => 'nuff said', + 'attrs' => { + 'automnt_dir' => 'a', + 'automnt_src' => 'b', + 'country' => 'c', + 'dm_allow_shutdown' => 'd', + 'hw_graphic' => 'e', + 'hw_monitor' => 'f', + 'hw_mouse' => 'g', + 'late_dm' => 'h', + 'netbios_workgroup' => 'i', + 'nis_domain' => 'j', + 'nis_servers' => 'k', + 'sane_scanner' => 'p', + 'scratch' => 'q', + 'slxgrp' => 'r', + 'start_alsasound' => 's', + 'start_atd' => 't', + 'start_cron' => 'u', + 'start_dreshal' => 'v', + 'start_ntp' => 'w', + 'start_nfsv4' => 'x', + 'start_printer' => 'y', + 'start_samba' => 'z', + 'start_snmp' => 'A', + 'start_sshd' => 'B', + 'start_syslog' => 'C', + 'start_x' => 'D', + 'start_xdmcp' => 'E', + 'tex_enable' => 'F', + 'timezone' => 'G', + 'tvout' => 'H', + 'vmware' => 'I', + }, }; ok( my ($group2ID, $group3ID) = $configDB->addGroup([ @@ -61,10 +102,42 @@ is($group3ID, 3, 'group 3 should have ID=3'); # fetch group 3 by id and check all values ok(my $group3 = $configDB->fetchGroupByID(3), 'fetch group 3'); -is($group3->{id}, '3', 'group 3 - id'); -is($group3->{name}, 'grp-nr-3', 'group 3 - name'); -is($group3->{priority}, 50, 'group 3 - priority'); -is($group3->{comment}, 'nuff said', 'group 3 - comment'); +is($group3->{id}, '3', 'group 3 - id'); +is($group3->{name}, 'grp-nr-3', 'group 3 - name'); +is($group3->{priority}, 50, 'group 3 - priority'); +is($group3->{comment}, 'nuff said', 'group 3 - comment'); +is($group3->{attrs}->{automnt_dir}, 'a', 'group 3 - attr automnt_dir'); +is($group3->{attrs}->{automnt_src}, 'b', 'group 3 - attr automnt_src'); +is($group3->{attrs}->{country}, 'c', 'group 3 - attr country'); +is($group3->{attrs}->{dm_allow_shutdown}, 'd', 'group 3 - attr dm_allow_shutdown'); +is($group3->{attrs}->{hw_graphic}, 'e', 'group 3 - attr hw_graphic'); +is($group3->{attrs}->{hw_monitor}, 'f', 'group 3 - attr hw_monitor'); +is($group3->{attrs}->{hw_mouse}, 'g', 'group 3 - attr hw_mouse'); +is($group3->{attrs}->{late_dm}, 'h', 'group 3 - attr late_dm'); +is($group3->{attrs}->{netbios_workgroup}, 'i', 'group 3 - attr netbios_workgroup'); +is($group3->{attrs}->{nis_domain}, 'j', 'group 3 - attr nis_domain'); +is($group3->{attrs}->{nis_servers}, 'k', 'group 3 - attr nis_servers'); +is($group3->{attrs}->{sane_scanner}, 'p', 'group 3 - attr sane_scanner'); +is($group3->{attrs}->{scratch}, 'q', 'group 3 - attr scratch'); +is($group3->{attrs}->{slxgrp}, 'r', 'group 3 - attr slxgrp'); +is($group3->{attrs}->{start_alsasound}, 's', 'group 3 - attr start_alsasound'); +is($group3->{attrs}->{start_atd}, 't', 'group 3 - attr start_atd'); +is($group3->{attrs}->{start_cron}, 'u', 'group 3 - attr start_cron'); +is($group3->{attrs}->{start_dreshal}, 'v', 'group 3 - attr start_dreshal'); +is($group3->{attrs}->{start_ntp}, 'w', 'group 3 - attr start_ftp'); +is($group3->{attrs}->{start_nfsv4}, 'x', 'group 3 - attr start_nfsv4'); +is($group3->{attrs}->{start_printer}, 'y', 'group 3 - attr start_printer'); +is($group3->{attrs}->{start_samba}, 'z', 'group 3 - attr start_samba'); +is($group3->{attrs}->{start_snmp}, 'A', 'group 3 - attr start_snmp'); +is($group3->{attrs}->{start_sshd}, 'B', 'group 3 - attr start_sshd'); +is($group3->{attrs}->{start_syslog}, 'C', 'group 3 - attr start_syslog'); +is($group3->{attrs}->{start_x}, 'D', 'group 3 - attr start_x'); +is($group3->{attrs}->{start_xdmcp}, 'E', 'group 3 - attr start_xdmcp'); +is($group3->{attrs}->{tex_enable}, 'F', 'group 3 - attr tex_enable'); +is($group3->{attrs}->{timezone}, 'G', 'group 3 - attr timezone'); +is($group3->{attrs}->{tvout}, 'H', 'group 3 - attr tvout'); +is($group3->{attrs}->{vmware}, 'I', 'group 3 - attr vmware'); +is(keys %{$group3->{attrs}}, 31, 'group 3 - attribute count'); # fetch group 2 by a filter on id and check all values ok( @@ -75,16 +148,21 @@ is($group2->{id}, 2, 'group 2 - id'); is($group2->{name}, 'grp-2.0', 'group 2 - name'); is($group2->{priority}, 30, 'group 2 - priority'); is($group2->{comment}, undef, 'group 2 - comment'); +is(keys %{$group2->{attrs}}, 0, 'group 2 - attribute count'); # fetch group 1 by filter on name and check all values ok( my $group1 = $configDB->fetchGroupByFilter({ name => 'grp-1' }), 'fetch group 1 by filter on name' ); -is($group1->{id}, 1, 'group 1 - id'); -is($group1->{name}, 'grp-1', 'group 1 - name'); -is($group1->{priority}, 50, 'group 1 - priority'); -is($group1->{comment}, '', 'group 1 - comment'); +is($group1->{id}, 1, 'group 1 - id'); +is($group1->{name}, 'grp-1', 'group 1 - name'); +is($group1->{priority}, 50, 'group 1 - priority'); +is($group1->{comment}, '', 'group 1 - comment'); +is(keys %{$group1->{attrs}}, 3, 'group 1 - attribute count'); +is($group1->{attrs}->{slxgrp}, 'slxgrp', 'group 1 - attr slxgrp'); +is($group1->{attrs}->{start_snmp}, 'no', 'group 1 - attr start_snmp'); +is($group1->{attrs}->{start_sshd}, 'yes', 'group 1 - attr start_sshd'); # fetch groups 3 & 1 by id ok( @@ -121,6 +199,14 @@ is(@groups1And3, 2, 'should have got 2 groups'); is($groups1And3[0]->{id}, 1, 'first id should be 1'); is($groups1And3[1]->{id}, 3, 'second id should be 3'); +# fetch group 2 by filter on comment being undef'd +ok( + my @group2Only = $configDB->fetchGroupByFilter({ comment => undef }), + 'fetch group 2 by filter on comment being undefined' +); +is(@group2Only, 1, 'should have got 1 group'); +is($group2Only[0]->{id}, 2, 'first id should be 2'); + # try to fetch with multi-column filter ok( ($group1, $group3) @@ -142,6 +228,83 @@ is(@groups1And3, 2, 'should have got 2 groups'); is($groups1And3[0]->{id}, 1, 'first id should be 1'); is($groups1And3[1]->{id}, 3, 'second id should be 3'); +# filter groups by different attributes & values in combination +ok( + my @group1Only = $configDB->fetchGroupByFilter( {}, undef, { + start_snmp => 'no', + } ), + 'fetch group 1 by filter on attribute start_snmp' +); + +is(@group1Only, 1, 'should have got 1 group'); +is($group1Only[0]->{id}, 1, 'first id should be 1'); + +ok( + @group1Only = $configDB->fetchGroupByFilter( undef, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch group 1 by filter on attribute start_snmp + non-existing attr' +); +is(@group1Only, 1, 'should have got 1 group'); +is($group1Only[0]->{id}, 1, 'first id should be 1'); + +ok( + @group1Only = $configDB->fetchGroupByFilter( { + name => 'grp-1', + priority => 50, + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + 'fetch group 1 by multiple filter on values and attributes' +); +is(@group1Only, 1, 'should have got 1 group'); +is($group1Only[0]->{id}, 1, 'first id should be 1'); + +is( + $configDB->fetchGroupByFilter( { + comment => 'xxx', + }, 'id', { + start_snmp => 'no', + tex_enable => undef, + } ), + undef, + 'mismatch group 1 by filter with incorrect value' +); +is( + $configDB->fetchGroupByFilter( { + name => 'grp-1', + }, 'id', { + start_snmp => 'yes', + tex_enable => undef, + } ), + undef, + 'mismatch group 1 by filter with incorrect attribute value' +); +is( + $configDB->fetchGroupByFilter( { + name => 'grp-1', + }, 'id', { + start_sshd => undef, + } ), + undef, + 'mismatch group 1 by filter with attribute not being empty' +); + +# fetch groups 1 & 2 by filter on attribute start_samba not existing +ok( + my @groups1And2 = $configDB->fetchGroupByFilter( {}, undef, { + start_samba => undef, + } ), + 'fetch groups 1 & 2 by filter on attribute start_samba not existing' +); +is(@groups1And2, 2, 'should have got 2 groups'); +# now sort by ID and check if we have really got 1 and 2 +@groups1And2 = sort { $a->{id} cmp $b->{id} } @groups1And2; +is($groups1And2[0]->{id}, 1, 'first id should be 1'); +is($groups1And2[1]->{id}, 2, 'second id should be 2'); + # try to fetch a couple of non-existing groups by id is($configDB->fetchGroupByID(-1), undef, 'group with id -1 should not exist'); is($configDB->fetchGroupByID(0), undef, 'group with id 0 should not exist'); @@ -173,6 +336,9 @@ ok( is($group1->{id}, 1, 'really got group number 1'); is($group1->{name}, q{GRP-'1'}, q{really got group named "GRP-'1'"}); +# changing nothing at all should succeed +ok($configDB->changeGroup(1), 'changing nothing at all in group 1'); + # changing a non-existing column should fail ok( ! eval { $configDB->changeGroup(1, { xname => "xx" }) }, diff --git a/config-db/t/15-global_info.t b/config-db/t/15-global_info.t index 82c04997..628b2495 100644 --- a/config-db/t/15-global_info.t +++ b/config-db/t/15-global_info.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -10,7 +13,7 @@ $configDB->connect(); # fetch global-info 'next-nbd-server-port' ok( - $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'), + my $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'), 'fetch global-info' ); is($globalInfo, '5000', 'global-info - value'); diff --git a/config-db/t/20-client_system_ref.t b/config-db/t/20-client_system_ref.t index 646050e3..46e56ddf 100644 --- a/config-db/t/20-client_system_ref.t +++ b/config-db/t/20-client_system_ref.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -40,7 +43,7 @@ ok( 'system-ID 3 has been associated to client 1' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), + my @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)), 0, "default client should have no system-ID" ); is( @@ -53,7 +56,7 @@ is( 0, "client 3 should have no system-ID" ); is( - @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), + my @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)), 0, "default system should have no client-IDs" ); is( diff --git a/config-db/t/21-group_system_ref.t b/config-db/t/21-group_system_ref.t index e9023feb..6f92a8dd 100644 --- a/config-db/t/21-group_system_ref.t +++ b/config-db/t/21-group_system_ref.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -39,7 +42,7 @@ ok( 'system-ID 3 has been associated to group 1' ); is( - @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), + my @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)), 1, "group 1 should have one system-ID" ); is($systemIDs[0], 3, "first system of group 1 should have ID 3"); @@ -48,7 +51,7 @@ is( 0, "group 3 should have no system-ID" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), + my @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)), 0, "default system should have no group-IDs" ); is( diff --git a/config-db/t/22-group_client_ref.t b/config-db/t/22-group_client_ref.t index 240fcd61..d330bc23 100644 --- a/config-db/t/22-group_client_ref.t +++ b/config-db/t/22-group_client_ref.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -39,7 +42,7 @@ ok( 'client-ID 3 has been associated to group 1' ); is( - @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), + my @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)), 1, "group 1 should have one client-ID" ); is($clientIDs[0], 3, "first client of group 1 should have ID 3"); @@ -48,7 +51,7 @@ is( 0, "group 3 should have no client-ID" ); is( - @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), + my @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)), 0, "default client should have no group-IDs" ); is( diff --git a/config-db/t/25-attributes.t b/config-db/t/25-attributes.t index fe684679..ce83d037 100644 --- a/config-db/t/25-attributes.t +++ b/config-db/t/25-attributes.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init @@ -9,114 +12,114 @@ my $configDB = OpenSLX::ConfigDB->new; $configDB->connect(); my $defaultAttrs = { # mostly copied from DBSchema - 'attr_ramfs_fsmods' => '', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => 'de', - 'attr_dm_allow_shutdown' => 'user', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => 'no', - 'attr_netbios_workgroup' => 'slx-network', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => 'yes', - 'attr_start_atd' => 'no', - 'attr_start_cron' => 'no', - 'attr_start_dreshal' => 'yes', - 'attr_start_ntp' => 'initial', - 'attr_start_nfsv4' => 'no', - 'attr_start_printer' => 'no', - 'attr_start_samba' => 'may', - 'attr_start_snmp' => 'no', - 'attr_start_sshd' => 'yes', - 'attr_start_syslog' => 'yes', - 'attr_start_x' => 'yes', - 'attr_start_xdmcp' => 'kdm', - 'attr_tex_enable' => 'no', - 'attr_timezone' => 'Europe/Berlin', - 'attr_tvout' => 'no', - 'attr_vmware' => 'no', + 'ramfs_fsmods' => '', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '', + 'slxgrp' => '', + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'no', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'yes', + 'start_xdmcp' => 'kdm', + 'tex_enable' => 'no', + 'timezone' => 'Europe/Berlin', + 'tvout' => 'no', + 'vmware' => 'no', }; ok( - $configDB->changeSystem(0, $defaultAttrs), + $configDB->changeSystem(0, { attrs => $defaultAttrs } ), 'attributes of default system have been set' ); my $defaultSystem = $configDB->fetchSystemByID(0); my $system1 = $configDB->fetchSystemByID(1); my $sys1Attrs = { - 'attr_ramfs_fsmods' => 'squashfs', - 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169', - 'attr_start_x' => 'no', - 'attr_start_xdmcp' => '', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + 'start_x' => 'no', + 'start_xdmcp' => '', }; ok( - $configDB->changeSystem(1, $sys1Attrs), + $configDB->changeSystem(1, { attrs => $sys1Attrs } ), 'attributes of system 1 have been set' ); my $system3 = $configDB->fetchSystemByID(3); my $sys3Attrs = { - 'attr_ramfs_fsmods' => '-4', - 'attr_ramfs_miscmods' => '-3', - 'attr_ramfs_nicmods' => '-2', - 'attr_ramfs_screen' => '-1', - - 'attr_automnt_dir' => '1', - 'attr_automnt_src' => '2', - 'attr_country' => '3', - 'attr_dm_allow_shutdown' => '4', - 'attr_hw_graphic' => '5', - 'attr_hw_monitor' => '6', - 'attr_hw_mouse' => '7', - 'attr_late_dm' => '8', - 'attr_netbios_workgroup' => '9', - 'attr_nis_domain' => '10', - 'attr_nis_servers' => '11', - 'attr_sane_scanner' => '12', - 'attr_scratch' => '13', - 'attr_slxgrp' => '14', - 'attr_start_alsasound' => '15', - 'attr_start_atd' => '16', - 'attr_start_cron' => '17', - 'attr_start_dreshal' => '18', - 'attr_start_ntp' => '19', - 'attr_start_nfsv4' => '20', - 'attr_start_printer' => '21', - 'attr_start_samba' => '22', - 'attr_start_snmp' => '23', - 'attr_start_sshd' => '24', - 'attr_start_syslog' => '25', - 'attr_start_x' => '26', - 'attr_start_xdmcp' => '27', - 'attr_tex_enable' => '28', - 'attr_timezone' => '29', - 'attr_tvout' => '30', - 'attr_vmware' => '31', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + 'ramfs_screen' => '-1', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '13', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => '23', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => '29', + 'tvout' => '30', + 'vmware' => '31', }; ok( - $configDB->changeSystem(3, $sys3Attrs), + $configDB->changeSystem(3, { attrs => $sys3Attrs } ), 'attributes of system 3 have been set' ); my $defaultClient = $configDB->fetchClientByID(0); my $defaultClientAttrs = { # pretend the whole computer centre has been warped to London ;-) - 'attr_timezone' => 'Europe/London', + 'timezone' => 'Europe/London', # pretend we wanted to activate snmp globally (e.g. for testing) - 'attr_start_snmp' => 'yes', + 'start_snmp' => 'yes', }; ok( - $configDB->changeClient(0, $defaultClientAttrs), + $configDB->changeClient(0, { attrs => $defaultClientAttrs } ), 'attributes of default client have been set' ); @@ -124,42 +127,42 @@ ok( # default system attributes overruled by system attributes overruled by # default client attributes: my $shouldBeAttrs1 = { - 'attr_ramfs_fsmods' => 'squashfs', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => 'de', - 'attr_dm_allow_shutdown' => 'user', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => 'no', - 'attr_netbios_workgroup' => 'slx-network', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => 'yes', - 'attr_start_atd' => 'no', - 'attr_start_cron' => 'no', - 'attr_start_dreshal' => 'yes', - 'attr_start_ntp' => 'initial', - 'attr_start_nfsv4' => 'no', - 'attr_start_printer' => 'no', - 'attr_start_samba' => 'may', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => 'yes', - 'attr_start_syslog' => 'yes', - 'attr_start_x' => 'no', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => 'no', - 'attr_timezone' => 'Europe/London', - 'attr_tvout' => 'no', - 'attr_vmware' => 'no', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '', + 'slxgrp' => '', + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'yes', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'no', + 'start_xdmcp' => '', + 'tex_enable' => 'no', + 'timezone' => 'Europe/London', + 'tvout' => 'no', + 'vmware' => 'no', }; my $mergedSystem1 = $configDB->fetchSystemByID(1); ok( @@ -168,49 +171,49 @@ ok( ); foreach my $key (sort keys %$shouldBeAttrs1) { is( - $mergedSystem1->{$key} || '', $shouldBeAttrs1->{$key} || '', + $mergedSystem1->{attrs}->{$key}, $shouldBeAttrs1->{$key}, "checking merged attribute $key for system 1" ); } # check merging code for completeness (using all attributes): my $shouldBeAttrs3 = { - 'attr_ramfs_fsmods' => '-4', - 'attr_ramfs_miscmods' => '-3', - 'attr_ramfs_nicmods' => '-2', - 'attr_ramfs_screen' => '-1', - - 'attr_automnt_dir' => '1', - 'attr_automnt_src' => '2', - 'attr_country' => '3', - 'attr_dm_allow_shutdown' => '4', - 'attr_hw_graphic' => '5', - 'attr_hw_monitor' => '6', - 'attr_hw_mouse' => '7', - 'attr_late_dm' => '8', - 'attr_netbios_workgroup' => '9', - 'attr_nis_domain' => '10', - 'attr_nis_servers' => '11', - 'attr_sane_scanner' => '12', - 'attr_scratch' => '13', - 'attr_slxgrp' => '14', - 'attr_start_alsasound' => '15', - 'attr_start_atd' => '16', - 'attr_start_cron' => '17', - 'attr_start_dreshal' => '18', - 'attr_start_ntp' => '19', - 'attr_start_nfsv4' => '20', - 'attr_start_printer' => '21', - 'attr_start_samba' => '22', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '24', - 'attr_start_syslog' => '25', - 'attr_start_x' => '26', - 'attr_start_xdmcp' => '27', - 'attr_tex_enable' => '28', - 'attr_timezone' => 'Europe/London', - 'attr_tvout' => '30', - 'attr_vmware' => '31', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + 'ramfs_screen' => '-1', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '13', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => 'yes', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => 'Europe/London', + 'tvout' => '30', + 'vmware' => '31', }; my $mergedSystem3 = $configDB->fetchSystemByID(3); ok( @@ -219,7 +222,7 @@ ok( ); foreach my $key (sort keys %$shouldBeAttrs3) { is( - $mergedSystem3->{$key}, $shouldBeAttrs3->{$key}, + $mergedSystem3->{attrs}->{$key}, $shouldBeAttrs3->{$key}, "checking merged attribute $key for system 3" ); } @@ -229,34 +232,34 @@ my $group1 = $configDB->fetchGroupByID(1); my $group1Attrs = { 'priority' => '50', # this group of clients is connected via underwater cable ... - 'attr_timezone' => 'America/New_York', + 'timezone' => 'America/New_York', # ... and use a local scratch partition - 'attr_scratch' => '/dev/sdd1', + 'scratch' => '/dev/sdd1', # the following should be a noop (as that attribute is system-specific) -# 'attr_ramfs_nicmods' => 'e1000', +# 'ramfs_nicmods' => 'e1000', }; ok( - $configDB->changeGroup(1, $group1Attrs), + $configDB->changeGroup(1, { attrs => $group1Attrs } ), 'attributes of group 1 have been set' ); my $group3 = $configDB->fetchGroupByID(3); my $group3Attrs = { 'priority' => '30', # this specific client group is older and thus has a different scratch - 'attr_scratch' => '/dev/hdd1', - 'attr_vmware' => 'yes', + 'scratch' => '/dev/hdd1', + 'vmware' => 'yes', }; ok( - $configDB->changeGroup(3, $group3Attrs), + $configDB->changeGroup(3, { attrs => $group3Attrs } ), 'attributes of group 3 have been set' ); my $client1 = $configDB->fetchClientByID(1); my $client1Attrs = { # this specific client uses yet another local scratch partition - 'attr_scratch' => '/dev/sdx3', + 'scratch' => '/dev/sdx3', }; ok( - $configDB->changeClient(1, $client1Attrs), + $configDB->changeClient(1, { attrs => $client1Attrs } ), 'attributes of client 1 have been set' ); ok( @@ -272,42 +275,42 @@ ok( # default client attributes overruled by group attributes (ordererd by priority) # overruled by specific client attributes: $shouldBeAttrs1 = { - 'attr_ramfs_fsmods' => '', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => '', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => '', - 'attr_dm_allow_shutdown' => '', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => '', - 'attr_netbios_workgroup' => '', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '/dev/sdx3', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => '', - 'attr_start_atd' => '', - 'attr_start_cron' => '', - 'attr_start_dreshal' => '', - 'attr_start_ntp' => '', - 'attr_start_nfsv4' => '', - 'attr_start_printer' => '', - 'attr_start_samba' => '', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '', - 'attr_start_syslog' => '', - 'attr_start_x' => '', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => '', - 'attr_timezone' => 'America/New_York', - 'attr_tvout' => '', - 'attr_vmware' => '', + 'ramfs_fsmods' => '', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => '', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => '', + 'dm_allow_shutdown' => '', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => '', + 'netbios_workgroup' => '', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '/dev/sdx3', + 'slxgrp' => '', + 'start_alsasound' => '', + 'start_atd' => '', + 'start_cron' => '', + 'start_dreshal' => '', + 'start_ntp' => '', + 'start_nfsv4' => '', + 'start_printer' => '', + 'start_samba' => '', + 'start_snmp' => 'yes', + 'start_sshd' => '', + 'start_syslog' => '', + 'start_x' => '', + 'start_xdmcp' => '', + 'tex_enable' => '', + 'timezone' => 'America/New_York', + 'tvout' => '', + 'vmware' => '', }; my $mergedClient1 = $configDB->fetchClientByID(1); ok( @@ -316,49 +319,53 @@ ok( ); foreach my $key (sort keys %$shouldBeAttrs1) { is( - $mergedClient1->{$key} || '', $shouldBeAttrs1->{$key} || '', + $mergedClient1->{attrs}->{$key} || '', $shouldBeAttrs1->{$key} || '', "checking merged attribute $key for client 1" ); } $shouldBeAttrs3 = { - 'attr_ramfs_fsmods' => '', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => '', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => '', - 'attr_dm_allow_shutdown' => '', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => '', - 'attr_netbios_workgroup' => '', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => '', - 'attr_start_atd' => '', - 'attr_start_cron' => '', - 'attr_start_dreshal' => '', - 'attr_start_ntp' => '', - 'attr_start_nfsv4' => '', - 'attr_start_printer' => '', - 'attr_start_samba' => '', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '', - 'attr_start_syslog' => '', - 'attr_start_x' => '', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => '', - 'attr_timezone' => 'Europe/London', - 'attr_tvout' => '', - 'attr_vmware' => '', + 'ramfs_fsmods' => '', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => '', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => '', + 'dm_allow_shutdown' => '', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => '', + 'netbios_workgroup' => '', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '', + 'slxgrp' => '', + 'start_alsasound' => '', + 'start_atd' => '', + 'start_cron' => '', + 'start_dreshal' => '', + 'start_ntp' => '', + 'start_nfsv4' => '', + 'start_printer' => '', + 'start_samba' => '', + 'start_snmp' => 'yes', + 'start_sshd' => '', + 'start_syslog' => '', + 'start_x' => '', + 'start_xdmcp' => '', + 'tex_enable' => '', + 'timezone' => 'Europe/London', + 'tvout' => '', + 'vmware' => '', }; + +# remove all attributes from client 3 +$configDB->changeClient(3, { attrs => {} } ); + my $mergedClient3 = $configDB->fetchClientByID(3); ok( $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3), @@ -366,7 +373,7 @@ ok( ); foreach my $key (sort keys %$shouldBeAttrs1) { is( - $mergedClient3->{$key} || '', $shouldBeAttrs3->{$key} || '', + $mergedClient3->{attrs}->{$key} || '', $shouldBeAttrs3->{$key} || '', "checking merged attribute $key for client 3" ); } @@ -377,42 +384,42 @@ ok( 'group-IDs of default client have been set' ); $shouldBeAttrs1 = { - 'attr_ramfs_fsmods' => '', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => '', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => '', - 'attr_dm_allow_shutdown' => '', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => '', - 'attr_netbios_workgroup' => '', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '/dev/sdx3', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => '', - 'attr_start_atd' => '', - 'attr_start_cron' => '', - 'attr_start_dreshal' => '', - 'attr_start_ntp' => '', - 'attr_start_nfsv4' => '', - 'attr_start_printer' => '', - 'attr_start_samba' => '', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '', - 'attr_start_syslog' => '', - 'attr_start_x' => '', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => '', - 'attr_timezone' => 'America/New_York', - 'attr_tvout' => '', - 'attr_vmware' => 'yes', + 'ramfs_fsmods' => '', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => '', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => '', + 'dm_allow_shutdown' => '', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => '', + 'netbios_workgroup' => '', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '/dev/sdx3', + 'slxgrp' => '', + 'start_alsasound' => '', + 'start_atd' => '', + 'start_cron' => '', + 'start_dreshal' => '', + 'start_ntp' => '', + 'start_nfsv4' => '', + 'start_printer' => '', + 'start_samba' => '', + 'start_snmp' => 'yes', + 'start_sshd' => '', + 'start_syslog' => '', + 'start_x' => '', + 'start_xdmcp' => '', + 'tex_enable' => '', + 'timezone' => 'America/New_York', + 'tvout' => '', + 'vmware' => 'yes', }; $mergedClient1 = $configDB->fetchClientByID(1); ok( @@ -421,48 +428,48 @@ ok( ); foreach my $key (sort keys %$shouldBeAttrs1) { is( - $mergedClient1->{$key} || '', $shouldBeAttrs1->{$key} || '', + $mergedClient1->{attrs}->{$key} || '', $shouldBeAttrs1->{$key} || '', "checking merged attribute $key for client 1" ); } $shouldBeAttrs3 = { - 'attr_ramfs_fsmods' => '', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => '', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => '', - 'attr_dm_allow_shutdown' => '', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => '', - 'attr_netbios_workgroup' => '', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '/dev/hdd1', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => '', - 'attr_start_atd' => '', - 'attr_start_cron' => '', - 'attr_start_dreshal' => '', - 'attr_start_ntp' => '', - 'attr_start_nfsv4' => '', - 'attr_start_printer' => '', - 'attr_start_samba' => '', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '', - 'attr_start_syslog' => '', - 'attr_start_x' => '', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => '', - 'attr_timezone' => 'Europe/London', - 'attr_tvout' => '', - 'attr_vmware' => 'yes', + 'ramfs_fsmods' => '', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => '', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => '', + 'dm_allow_shutdown' => '', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => '', + 'netbios_workgroup' => '', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '/dev/hdd1', + 'slxgrp' => '', + 'start_alsasound' => '', + 'start_atd' => '', + 'start_cron' => '', + 'start_dreshal' => '', + 'start_ntp' => '', + 'start_nfsv4' => '', + 'start_printer' => '', + 'start_samba' => '', + 'start_snmp' => 'yes', + 'start_sshd' => '', + 'start_syslog' => '', + 'start_x' => '', + 'start_xdmcp' => '', + 'tex_enable' => '', + 'timezone' => 'Europe/London', + 'tvout' => '', + 'vmware' => 'yes', }; $mergedClient3 = $configDB->fetchClientByID(3); ok( @@ -471,7 +478,7 @@ ok( ); foreach my $key (sort keys %$shouldBeAttrs1) { is( - $mergedClient3->{$key} || '', $shouldBeAttrs3->{$key} || '', + $mergedClient3->{attrs}->{$key} || '', $shouldBeAttrs3->{$key} || '', "checking merged attribute $key for client 3" ); } @@ -483,46 +490,46 @@ ok( 'merging system 1 into client 1' ); my $shouldBeAttrs11 = { - 'attr_ramfs_fsmods' => 'squashfs', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => 'de', - 'attr_dm_allow_shutdown' => 'user', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => 'no', - 'attr_netbios_workgroup' => 'slx-network', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '/dev/sdx3', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => 'yes', - 'attr_start_atd' => 'no', - 'attr_start_cron' => 'no', - 'attr_start_dreshal' => 'yes', - 'attr_start_ntp' => 'initial', - 'attr_start_nfsv4' => 'no', - 'attr_start_printer' => 'no', - 'attr_start_samba' => 'may', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => 'yes', - 'attr_start_syslog' => 'yes', - 'attr_start_x' => 'no', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => 'no', - 'attr_timezone' => 'America/New_York', - 'attr_tvout' => 'no', - 'attr_vmware' => 'yes', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '/dev/sdx3', + 'slxgrp' => '', + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'yes', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'no', + 'start_xdmcp' => '', + 'tex_enable' => 'no', + 'timezone' => 'America/New_York', + 'tvout' => 'no', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs11) { is( - $fullMerge11->{$key} || '', $shouldBeAttrs11->{$key} || '', + $fullMerge11->{attrs}->{$key} || '', $shouldBeAttrs11->{$key} || '', "checking merged attribute $key for client 1 / system 1" ); } @@ -533,46 +540,46 @@ ok( 'merging system 1 into client 3' ); my $shouldBeAttrs31 = { - 'attr_ramfs_fsmods' => 'squashfs', - 'attr_ramfs_miscmods' => '', - 'attr_ramfs_nicmods' => 'forcedeth e1000 r8169', - 'attr_ramfs_screen' => '', - - 'attr_automnt_dir' => '', - 'attr_automnt_src' => '', - 'attr_country' => 'de', - 'attr_dm_allow_shutdown' => 'user', - 'attr_hw_graphic' => '', - 'attr_hw_monitor' => '', - 'attr_hw_mouse' => '', - 'attr_late_dm' => 'no', - 'attr_netbios_workgroup' => 'slx-network', - 'attr_nis_domain' => '', - 'attr_nis_servers' => '', - 'attr_sane_scanner' => '', - 'attr_scratch' => '/dev/hdd1', - 'attr_slxgrp' => '', - 'attr_start_alsasound' => 'yes', - 'attr_start_atd' => 'no', - 'attr_start_cron' => 'no', - 'attr_start_dreshal' => 'yes', - 'attr_start_ntp' => 'initial', - 'attr_start_nfsv4' => 'no', - 'attr_start_printer' => 'no', - 'attr_start_samba' => 'may', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => 'yes', - 'attr_start_syslog' => 'yes', - 'attr_start_x' => 'no', - 'attr_start_xdmcp' => '', - 'attr_tex_enable' => 'no', - 'attr_timezone' => 'Europe/London', - 'attr_tvout' => 'no', - 'attr_vmware' => 'yes', + 'ramfs_fsmods' => 'squashfs', + 'ramfs_miscmods' => '', + 'ramfs_nicmods' => 'forcedeth e1000 r8169', + 'ramfs_screen' => '', + + 'automnt_dir' => '', + 'automnt_src' => '', + 'country' => 'de', + 'dm_allow_shutdown' => 'user', + 'hw_graphic' => '', + 'hw_monitor' => '', + 'hw_mouse' => '', + 'late_dm' => 'no', + 'netbios_workgroup' => 'slx-network', + 'nis_domain' => '', + 'nis_servers' => '', + 'sane_scanner' => '', + 'scratch' => '/dev/hdd1', + 'slxgrp' => '', + 'start_alsasound' => 'yes', + 'start_atd' => 'no', + 'start_cron' => 'no', + 'start_dreshal' => 'yes', + 'start_ntp' => 'initial', + 'start_nfsv4' => 'no', + 'start_printer' => 'no', + 'start_samba' => 'may', + 'start_snmp' => 'yes', + 'start_sshd' => 'yes', + 'start_syslog' => 'yes', + 'start_x' => 'no', + 'start_xdmcp' => '', + 'tex_enable' => 'no', + 'timezone' => 'Europe/London', + 'tvout' => 'no', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs31) { is( - $fullMerge31->{$key} || '', $shouldBeAttrs31->{$key} || '', + $fullMerge31->{attrs}->{$key} || '', $shouldBeAttrs31->{$key} || '', "checking merged attribute $key for client 3 / system 1" ); } @@ -583,46 +590,46 @@ ok( 'merging system 3 into client 1' ); my $shouldBeAttrs13 = { - 'attr_ramfs_fsmods' => '-4', - 'attr_ramfs_miscmods' => '-3', - 'attr_ramfs_nicmods' => '-2', - 'attr_ramfs_screen' => '-1', - - 'attr_automnt_dir' => '1', - 'attr_automnt_src' => '2', - 'attr_country' => '3', - 'attr_dm_allow_shutdown' => '4', - 'attr_hw_graphic' => '5', - 'attr_hw_monitor' => '6', - 'attr_hw_mouse' => '7', - 'attr_late_dm' => '8', - 'attr_netbios_workgroup' => '9', - 'attr_nis_domain' => '10', - 'attr_nis_servers' => '11', - 'attr_sane_scanner' => '12', - 'attr_scratch' => '/dev/sdx3', - 'attr_slxgrp' => '14', - 'attr_start_alsasound' => '15', - 'attr_start_atd' => '16', - 'attr_start_cron' => '17', - 'attr_start_dreshal' => '18', - 'attr_start_ntp' => '19', - 'attr_start_nfsv4' => '20', - 'attr_start_printer' => '21', - 'attr_start_samba' => '22', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '24', - 'attr_start_syslog' => '25', - 'attr_start_x' => '26', - 'attr_start_xdmcp' => '27', - 'attr_tex_enable' => '28', - 'attr_timezone' => 'America/New_York', - 'attr_tvout' => '30', - 'attr_vmware' => 'yes', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + 'ramfs_screen' => '-1', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '/dev/sdx3', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => 'yes', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => 'America/New_York', + 'tvout' => '30', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs13) { is( - $fullMerge13->{$key} || '', $shouldBeAttrs13->{$key} || '', + $fullMerge13->{attrs}->{$key} || '', $shouldBeAttrs13->{$key} || '', "checking merged attribute $key for client 1 / system 3" ); } @@ -633,46 +640,46 @@ ok( 'merging system 3 into client 3' ); my $shouldBeAttrs33 = { - 'attr_ramfs_fsmods' => '-4', - 'attr_ramfs_miscmods' => '-3', - 'attr_ramfs_nicmods' => '-2', - 'attr_ramfs_screen' => '-1', - - 'attr_automnt_dir' => '1', - 'attr_automnt_src' => '2', - 'attr_country' => '3', - 'attr_dm_allow_shutdown' => '4', - 'attr_hw_graphic' => '5', - 'attr_hw_monitor' => '6', - 'attr_hw_mouse' => '7', - 'attr_late_dm' => '8', - 'attr_netbios_workgroup' => '9', - 'attr_nis_domain' => '10', - 'attr_nis_servers' => '11', - 'attr_sane_scanner' => '12', - 'attr_scratch' => '/dev/hdd1', - 'attr_slxgrp' => '14', - 'attr_start_alsasound' => '15', - 'attr_start_atd' => '16', - 'attr_start_cron' => '17', - 'attr_start_dreshal' => '18', - 'attr_start_ntp' => '19', - 'attr_start_nfsv4' => '20', - 'attr_start_printer' => '21', - 'attr_start_samba' => '22', - 'attr_start_snmp' => 'yes', - 'attr_start_sshd' => '24', - 'attr_start_syslog' => '25', - 'attr_start_x' => '26', - 'attr_start_xdmcp' => '27', - 'attr_tex_enable' => '28', - 'attr_timezone' => 'Europe/London', - 'attr_tvout' => '30', - 'attr_vmware' => 'yes', + 'ramfs_fsmods' => '-4', + 'ramfs_miscmods' => '-3', + 'ramfs_nicmods' => '-2', + 'ramfs_screen' => '-1', + + 'automnt_dir' => '1', + 'automnt_src' => '2', + 'country' => '3', + 'dm_allow_shutdown' => '4', + 'hw_graphic' => '5', + 'hw_monitor' => '6', + 'hw_mouse' => '7', + 'late_dm' => '8', + 'netbios_workgroup' => '9', + 'nis_domain' => '10', + 'nis_servers' => '11', + 'sane_scanner' => '12', + 'scratch' => '/dev/hdd1', + 'slxgrp' => '14', + 'start_alsasound' => '15', + 'start_atd' => '16', + 'start_cron' => '17', + 'start_dreshal' => '18', + 'start_ntp' => '19', + 'start_nfsv4' => '20', + 'start_printer' => '21', + 'start_samba' => '22', + 'start_snmp' => 'yes', + 'start_sshd' => '24', + 'start_syslog' => '25', + 'start_x' => '26', + 'start_xdmcp' => '27', + 'tex_enable' => '28', + 'timezone' => 'Europe/London', + 'tvout' => '30', + 'vmware' => 'yes', }; foreach my $key (sort keys %$shouldBeAttrs33) { is( - $fullMerge33->{$key} || '', $shouldBeAttrs33->{$key} || '', + $fullMerge33->{attrs}->{$key} || '', $shouldBeAttrs33->{$key} || '', "checking merged attribute $key for client 3 / system 3" ); } diff --git a/config-db/t/29-transaction.t b/config-db/t/29-transaction.t index 89b0df83..2088a16c 100644 --- a/config-db/t/29-transaction.t +++ b/config-db/t/29-transaction.t @@ -1,5 +1,8 @@ use Test::More qw(no_plan); +use strict; +use warnings; + use lib '/opt/openslx/lib'; # basic init -- cgit v1.2.3-55-g7522