summaryrefslogtreecommitdiffstats
path: root/src/config-db/t
diff options
context:
space:
mode:
authorSebastian Schmelzer2010-09-02 17:50:49 +0200
committerSebastian Schmelzer2010-09-02 17:50:49 +0200
commit416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5 (patch)
tree4715f7d742fec50931017f38fe6ff0a89d4ceccc /src/config-db/t
parentFix for the problem reported on the list (sed filter forgotten for the (diff)
downloadcore-416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5.tar.gz
core-416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5.tar.xz
core-416ab8a37f1b07dc9f6c0fb3ff1a8ff2036510b5.zip
change dir structure
Diffstat (limited to 'src/config-db/t')
-rw-r--r--src/config-db/t/01-basics.t23
-rw-r--r--src/config-db/t/10-vendor-os.t258
-rw-r--r--src/config-db/t/11-export.t247
-rw-r--r--src/config-db/t/12-system.t360
-rw-r--r--src/config-db/t/13-client.t320
-rw-r--r--src/config-db/t/14-group.t384
-rw-r--r--src/config-db/t/15-global_info.t43
-rw-r--r--src/config-db/t/20-client_system_ref.t208
-rw-r--r--src/config-db/t/21-group_system_ref.t195
-rw-r--r--src/config-db/t/22-group_client_ref.t186
-rw-r--r--src/config-db/t/25-attributes.t677
-rw-r--r--src/config-db/t/29-transaction.t58
-rwxr-xr-xsrc/config-db/t/run-all-tests.pl36
13 files changed, 2995 insertions, 0 deletions
diff --git a/src/config-db/t/01-basics.t b/src/config-db/t/01-basics.t
new file mode 100644
index 00000000..1fb7083b
--- /dev/null
+++ b/src/config-db/t/01-basics.t
@@ -0,0 +1,23 @@
+use Test::More qw(no_plan);
+
+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');
+
+{
+ # create a second object - should work and yield different objects
+ ok(my $configDB2 = OpenSLX::ConfigDB->new, 'can create another object');
+ cmp_ok($configDB, 'ne', $configDB2, 'should have two different objects now');
+}
+
+ok($configDB->connect(), 'connecting');
+ok($configDB->disconnect(), 'disconnecting');
+
diff --git a/src/config-db/t/10-vendor-os.t b/src/config-db/t/10-vendor-os.t
new file mode 100644
index 00000000..a71ee4ac
--- /dev/null
+++ b/src/config-db/t/10-vendor-os.t
@@ -0,0 +1,258 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+is(
+ my $vendorOS = $configDB->fetchVendorOSByFilter, undef,
+ 'no vendor-OS yet (scalar context)'
+);
+
+my $wrongVendorOS = {
+ 'comment' => 'test',
+};
+ok(
+ ! eval { my $vendorOSID = $configDB->addVendorOS($wrongVendorOS); },
+ 'trying to insert an unnamed vendor-OS should fail'
+);
+
+is(
+ my @vendorOSes = $configDB->fetchVendorOSByFilter, 0,
+ 'no vendor-OS yet (array context)'
+);
+
+my $inVendorOS1 = {
+ 'name' => 'vos-1',
+ 'comment' => '',
+};
+is(
+ my $vendorOS1ID = $configDB->addVendorOS($inVendorOS1), 1,
+ 'first vendor-OS has ID 1'
+);
+
+my $inVendorOS2 = {
+ 'name' => 'vos-2.0',
+ 'comment' => 'batch 2',
+};
+my $inVendorOS3 = {
+ 'name' => 'vos-3.0',
+ 'comment' => 'batch 2',
+ 'clone_source' => 'kiwi::test-vos',
+};
+ok(
+ my ($vendorOS2ID, $vendorOS3ID) = $configDB->addVendorOS([
+ $inVendorOS2, $inVendorOS3
+ ]),
+ 'add two more vendor-OSes'
+);
+is($vendorOS2ID, 2, 'vendor-OS 2 should have ID=2');
+is($vendorOS3ID, 3, 'vendor-OS 3 should have ID=3');
+
+# fetch vendor-OS 3 by id and check all values
+ok(my $vendorOS3 = $configDB->fetchVendorOSByID(3), 'fetch vendor-OS 3');
+is($vendorOS3->{id}, 3, 'vendor-OS 3 - id');
+is($vendorOS3->{name}, 'vos-3.0', 'vendor-OS 3 - name');
+is($vendorOS3->{comment}, 'batch 2', 'vendor-OS 3 - comment');
+is($vendorOS3->{clone_source}, 'kiwi::test-vos', 'vendor-OS 3 - clone_source');
+
+# fetch vendor-OS 2 by a filter on id and check all values
+ok(
+ my $vendorOS2 = $configDB->fetchVendorOSByFilter({ id => 2 }),
+ 'fetch vendor-OS 2 by filter on id'
+);
+is($vendorOS2->{id}, 2, 'vendor-OS 2 - id');
+is($vendorOS2->{name}, 'vos-2.0', 'vendor-OS 2 - name');
+is($vendorOS2->{comment}, 'batch 2', 'vendor-OS 2 - comment');
+is($vendorOS2->{clone_source}, undef, 'vendor-OS 2 - clone_source');
+
+# fetch vendor-OS 1 by filter on name and check all values
+ok(
+ my $vendorOS1 = $configDB->fetchVendorOSByFilter({ name => 'vos-1' }),
+ 'fetch vendor-OS 1 by filter on name'
+);
+is($vendorOS1->{id}, 1, 'vendor-OS 1 - id');
+is($vendorOS1->{name}, 'vos-1', 'vendor-OS 1 - name');
+is($vendorOS1->{comment}, '', 'vendor-OS 1 - comment');
+is($vendorOS1->{clone_source}, undef, 'vendor-OS 1 - clone_source');
+
+# fetch vendor-OSes 3 & 1 by id
+ok(
+ my @vendorOSes3And1
+ = $configDB->fetchVendorOSByID([3, 1]),
+ 'fetch vendor-OSes 3 & 1 by id'
+);
+is(@vendorOSes3And1, 2, 'should have got 2 vendor-OSes');
+# now sort by ID and check if we have really got 3 and 1
+@vendorOSes3And1 = sort { $a->{id} cmp $b->{id} } @vendorOSes3And1;
+is($vendorOSes3And1[0]->{id}, 1, 'first id should be 1');
+is($vendorOSes3And1[1]->{id}, 3, 'second id should be 3');
+
+# fetching vendor-OSes by id without giving any should yield undef
+is(
+ $configDB->fetchVendorOSByID(), undef,
+ 'fetch vendor-OSes by id without giving any'
+);
+
+# fetching vendor-OSes by filter without giving any should yield all of them
+ok(
+ @vendorOSes = $configDB->fetchVendorOSByFilter(),
+ 'fetch vendor-OSes by filter without giving any'
+);
+is(@vendorOSes, 3, 'should have got all three vendor-OSes');
+
+# fetch vendor-OSes 2 & 3 by filter on comment
+ok(
+ my @vendorOSes2And3
+ = $configDB->fetchVendorOSByFilter({ comment => 'batch 2' }),
+ 'fetch vendor-OSes 2 & 3 by filter on comment'
+);
+is(@vendorOSes2And3, 2, 'should have got 2 vendor-OSes');
+# now sort by ID and check if we have really got 2 and 3
+@vendorOSes2And3 = sort { $a->{id} cmp $b->{id} } @vendorOSes2And3;
+is($vendorOSes2And3[0]->{id}, 2, 'first id should be 2');
+is($vendorOSes2And3[1]->{id}, 3, 'second id should be 3');
+
+# try to fetch with multi-column filter
+ok(
+ ($vendorOS2, $vendorOS3)
+ = $configDB->fetchVendorOSByFilter({ comment => 'batch 2', id => 2 }),
+ 'fetching vendor-OS with comment="batch 2" and id=2 should work'
+);
+is($vendorOS2->{name}, 'vos-2.0', 'should have got vos-2.0');
+is($vendorOS3, undef, 'should not get vos-3.0');
+
+# try to fetch multiple occurrences of the same vendor-OS, combined with
+# some unknown IDs
+ok(
+ my @vendorOSes1And3
+ = $configDB->fetchVendorOSByID([ 1, 21, 4-1, 1, 0, 1, 1 ]),
+ 'fetch a complex set of vendor-OSes by ID'
+);
+is(@vendorOSes1And3, 2, 'should have got 2 vendor-OSes');
+# now sort by ID and check if we have really got 1 and 3
+@vendorOSes1And3 = sort { $a->{id} cmp $b->{id} } @vendorOSes1And3;
+is($vendorOSes1And3[0]->{id}, 1, 'first id should be 1');
+is($vendorOSes1And3[1]->{id}, 3, 'second id should be 3');
+
+# try to fetch a couple of non-existing vendor-OSes by id
+is(
+ $configDB->fetchVendorOSByID(-1), undef,
+ 'vendor-OS with id -1 should not exist'
+);
+is(
+ $configDB->fetchVendorOSByID(0), undef,
+ 'vendor-OS with id 0 should not exist'
+);
+is(
+ $configDB->fetchVendorOSByID(1 << 31 + 1000), undef,
+ 'trying to fetch another unknown vendor-OS'
+);
+
+# try to fetch a couple of non-existing vendor-OSes by filter
+is(
+ $configDB->fetchVendorOSByFilter({ id => 0 }), undef,
+ 'fetching vendor-OS with id=0 by filter should fail'
+);
+is(
+ $configDB->fetchVendorOSByFilter({ name => 'vos-1.x' }), undef,
+ 'fetching vendor-OS with name="vos-1.x" should fail'
+);
+is(
+ $configDB->fetchVendorOSByFilter({ comment => 'batch 2', id => 1 }), undef,
+ 'fetching vendor-OS with comment="batch 2" and id=1 should fail'
+);
+
+# rename vendor-OS 1 and then fetch it by its new name
+ok($configDB->changeVendorOS(1, { name => q{VOS-'1'} }), 'changing vendor-OS 1');
+ok(
+ $vendorOS1 = $configDB->fetchVendorOSByFilter({ name => q{VOS-'1'} }),
+ 'fetching renamed vendor-OS 1'
+);
+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" }) },
+ 'changing unknown colum should fail'
+);
+
+ok(! $configDB->changeVendorOS(1, { id => 23 }), 'changing id should fail');
+
+# test adding & removing of installed plugins
+is(
+ my @plugins = $configDB->fetchInstalledPlugins(3),
+ 0, 'there should be no installed plugins'
+);
+ok($configDB->addInstalledPlugin(3, 'Example'), 'adding installed plugin');
+is(
+ @plugins = $configDB->fetchInstalledPlugins(3),
+ 1,
+ 'should have 1 installed plugin'
+);
+is(
+ $configDB->addInstalledPlugin(3, 'Example'), 1,
+ 'adding plugin again should work (but do not harm, just update the attrs)'
+);
+is(
+ @plugins = $configDB->fetchInstalledPlugins(3),
+ 1,
+ 'should still have 1 installed plugin'
+);
+is($plugins[0]->{plugin_name}, 'Example', 'should have got plugin "Example"');
+ok($configDB->addInstalledPlugin(3, 'Test'), 'adding a second plugin');
+is(
+ @plugins = $configDB->fetchInstalledPlugins(3),
+ 2,
+ 'should have 2 installed plugin'
+);
+ok(
+ !$configDB->removeInstalledPlugin(3, 'xxx'),
+ 'removing unknown plugin should fail'
+);
+ok(
+ @plugins = $configDB->fetchInstalledPlugins(3, 'Example'),
+ 'fetching specific plugin'
+);
+is($plugins[0]->{plugin_name}, 'Example', 'should have got plugin "Example"');
+ok(
+ @plugins = $configDB->fetchInstalledPlugins(3, 'Test'),
+ 'fetching another specific plugin'
+);
+is($plugins[0]->{plugin_name}, 'Test', 'should have got plugin "Test"');
+is(
+ @plugins = $configDB->fetchInstalledPlugins(3, 'xxx'), 0,
+ 'fetching unknown specific plugin'
+);
+ok($configDB->removeInstalledPlugin(3, 'Example'), 'removing installed plugin');
+is(
+ @plugins = $configDB->fetchInstalledPlugins(3),
+ 1,
+ 'should have 1 installed plugin'
+);
+ok($configDB->removeInstalledPlugin(3, 'Test'), 'removing second plugin');
+is(
+ @plugins = $configDB->fetchInstalledPlugins(3),
+ 0,
+ 'should have no installed plugins'
+);
+
+# now remove a vendor-OS and check if that worked
+ok($configDB->removeVendorOS(3), 'removing vendor-OS 3 should be ok');
+is($configDB->fetchVendorOSByID(3, 'id'), undef, 'vendor-OS 3 should be gone');
+is($configDB->fetchVendorOSByID(1)->{id}, 1, 'vendor-OS 1 should still exist');
+is($configDB->fetchVendorOSByID(2)->{id}, 2, 'vendor-OS 2 should still exist');
+
+$configDB->disconnect();
+
diff --git a/src/config-db/t/11-export.t b/src/config-db/t/11-export.t
new file mode 100644
index 00000000..3dd0ae6c
--- /dev/null
+++ b/src/config-db/t/11-export.t
@@ -0,0 +1,247 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+is(
+ my $export = $configDB->fetchExportByFilter, undef,
+ 'no export yet (scalar context)'
+);
+
+foreach my $requiredCol (qw(name vendor_os_id type)) {
+ my $wrongExport = {
+ 'name' => 'name',
+ 'vendor_os_id' => 1,
+ 'type ' => 'nfs',
+ 'comment' => 'has column missing',
+ };
+ delete $wrongExport->{$requiredCol};
+ ok(
+ ! eval { my $exportID = $configDB->addExport($wrongExport); },
+ "inserting an export without '$requiredCol' column should fail"
+ );
+}
+
+is(
+ my @exports = $configDB->fetchExportByFilter, 0,
+ 'no export yet (array context)'
+);
+
+is(
+ my @exportIDs = $configDB->fetchExportIDsOfVendorOS(1), 0,
+ 'vendor-OS 1 has no export IDs yet'
+);
+
+is(
+ @exportIDs = $configDB->fetchExportIDsOfVendorOS(2), 0,
+ 'vendor-OS 2 has no export IDs yet'
+);
+
+my $inExport1 = {
+ 'name' => 'exp-1',
+ 'type' => 'nfs',
+ 'vendor_os_id' => 1,
+ 'comment' => '',
+};
+is(
+ my $export1ID = $configDB->addExport($inExport1), 1,
+ 'first export has ID 1'
+);
+
+my $inExport2 = {
+ 'name' => 'exp-2.0',
+ 'type' => 'sqfs-nbd',
+ 'vendor_os_id' => 1,
+ 'comment' => undef,
+};
+my $fullExport = {
+ 'name' => 'exp-nr-3',
+ 'type' => 'sqfs-nbd',
+ 'vendor_os_id' => 2,
+ 'comment' => 'nuff said',
+ 'server_ip' => '192.168.212.243',
+ 'port' => '65432',
+ 'uri' => 'sqfs-nbd://somehost/somepath?param=val&yes=1',
+};
+ok(
+ my ($export2ID, $export3ID) = $configDB->addExport([
+ $inExport2, $fullExport
+ ]),
+ 'add two more exports'
+);
+is($export2ID, 2, 'export 2 should have ID=2');
+is($export3ID, 3, 'export 3 should have ID=3');
+
+# fetch export 3 by id and check all values
+ok(my $export3 = $configDB->fetchExportByID(3), 'fetch export 3');
+is($export3->{id}, 3, 'export 3 - id');
+is($export3->{name}, 'exp-nr-3', 'export 3 - name');
+is($export3->{type}, 'sqfs-nbd', 'export 3 - type');
+is($export3->{vendor_os_id}, '2', 'export 3 - vendor_os_id');
+is($export3->{comment}, 'nuff said', 'export 3 - comment');
+is($export3->{server_ip}, '192.168.212.243', 'export 3 - server_ip');
+is($export3->{port}, '65432', 'export 3 - port');
+is(
+ $export3->{uri},
+ 'sqfs-nbd://somehost/somepath?param=val&yes=1',
+ 'export 3 - uri'
+);
+
+# fetch export 2 by a filter on id and check all values
+ok(
+ my $export2 = $configDB->fetchExportByFilter({ id => 2 }),
+ 'fetch export 2 by filter on id'
+);
+is($export2->{id}, 2, 'export 2 - id');
+is($export2->{name}, 'exp-2.0', 'export 2 - name');
+is($export2->{type}, 'sqfs-nbd', 'export 2 - type');
+is($export2->{vendor_os_id}, '1', 'export 2 - vendor_os_id');
+is($export2->{comment}, undef, 'export 2 - comment');
+
+# fetch export 1 by filter on name and check all values
+ok(
+ my $export1 = $configDB->fetchExportByFilter({ name => 'exp-1' }),
+ 'fetch export 1 by filter on name'
+);
+is($export1->{id}, 1, 'export 1 - id');
+is($export1->{name}, 'exp-1', 'export 1 - name');
+is($export1->{vendor_os_id}, '1', 'export 1 - vendor_os_id');
+is($export1->{type}, 'nfs', 'export 1 - type');
+is($export1->{comment}, '', 'export 1 - comment');
+is($export1->{port}, undef, 'export 1 - port');
+is($export1->{server_ip}, undef, 'export 1 - server_ip');
+is($export1->{uri}, undef, 'export 1 - uri');
+
+is(
+ @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(1)),
+ 2, 'vendor-OS 1 has two export IDs'
+);
+is($exportIDs[0], 1, 'first export ID of vendor-OS 1 (1)');
+is($exportIDs[1], 2, 'second export ID of vendor-OS 1 (2)');
+
+is(
+ @exportIDs = sort( { $a <=> $b } $configDB->fetchExportIDsOfVendorOS(2)),
+ 1, 'vendor-OS 2 has one export IDs'
+);
+is($exportIDs[0], 3, 'first export ID of vendor-OS 2 (3)');
+
+# fetch exports 3 & 1 by id
+ok(
+ my @exports3And1 = $configDB->fetchExportByID([3, 1]),
+ 'fetch exports 3 & 1 by id'
+);
+is(@exports3And1, 2, 'should have got 2 exports');
+# now sort by ID and check if we have really got 3 and 1
+@exports3And1 = sort { $a->{id} cmp $b->{id} } @exports3And1;
+is($exports3And1[0]->{id}, 1, 'first id should be 1');
+is($exports3And1[1]->{id}, 3, 'second id should be 3');
+
+# fetching exports by id without giving any should yield undef
+is(
+ $configDB->fetchExportByID(), undef,
+ 'fetch exports by id without giving any'
+);
+
+# fetching exports by filter without giving any should yield all of them
+ok(
+ @exports = $configDB->fetchExportByFilter(),
+ 'fetch exports by filter without giving any'
+);
+is(@exports, 3, 'should have got all three exports');
+
+# fetch exports 1 & 2 by filter on vendor_os_id
+ok(
+ my @exports1And2 = $configDB->fetchExportByFilter({ vendor_os_id => '1' }),
+ 'fetch exports 1 & 2 by filter on vendor_os_id'
+);
+is(@exports1And2, 2, 'should have got 2 exports');
+# now sort by ID and check if we have really got 1 and 2
+@exports1And2 = sort { $a->{id} cmp $b->{id} } @exports1And2;
+is($exports1And2[0]->{id}, 1, 'first id should be 1');
+is($exports1And2[1]->{id}, 2, 'second id should be 2');
+
+# try to fetch with multi-column filter
+ok(
+ ($export2, $export3)
+ = $configDB->fetchExportByFilter({ vendor_os_id => '1', id => 2 }),
+ 'fetching export with vendor_os_id=1 and id=2 should work'
+);
+is($export2->{name}, 'exp-2.0', 'should have got exp-2.0');
+is($export3, undef, 'should not get exp-nr-3');
+
+# try to fetch multiple occurrences of the same export, combined with
+# some unknown IDs
+ok(
+ my @exports1And3 = $configDB->fetchExportByID([ 1, 21, 4-1, 1, 0, 1, 1 ]),
+ 'fetch a complex set of exports by ID'
+);
+is(@exports1And3, 2, 'should have got 2 exports');
+# now sort by ID and check if we have really got 1 and 3
+@exports1And3 = sort { $a->{id} cmp $b->{id} } @exports1And3;
+is($exports1And3[0]->{id}, 1, 'first id should be 1');
+is($exports1And3[1]->{id}, 3, 'second id should be 3');
+
+# try to fetch a couple of non-existing exports by id
+is(
+ $configDB->fetchExportByID(-1), undef,
+ 'export with id -1 should not exist'
+);
+is(
+ $configDB->fetchExportByID(0), undef,
+ 'export with id 0 should not exist'
+);
+is(
+ $configDB->fetchExportByID(1 << 31 + 1000), undef,
+ 'trying to fetch another unknown export'
+);
+
+# try to fetch a couple of non-existing exports by filter
+is(
+ $configDB->fetchExportByFilter({ id => 0 }), undef,
+ 'fetching export with id=0 by filter should fail'
+);
+is(
+ $configDB->fetchExportByFilter({ name => 'exp-1.x' }), undef,
+ 'fetching export with name="exp-1.x" should fail'
+);
+is(
+ $configDB->fetchExportByFilter({ vendor_os_id => '2', id => 1 }), undef,
+ 'fetching export with vendor_os_id=2 and id=1 should fail'
+);
+
+# rename export 1 and then fetch it by its new name
+ok($configDB->changeExport(1, { name => q{EXP-'1'} }), 'changing export 1');
+ok(
+ $export1 = $configDB->fetchExportByFilter({ name => q{EXP-'1'} }),
+ 'fetching renamed export 1'
+);
+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" }) },
+ 'changing unknown colum should fail'
+);
+
+ok(! $configDB->changeExport(1, { id => 23 }), 'changing id should fail');
+
+# now remove an export and check if that worked
+ok($configDB->removeExport(2), 'removing export 2 should be ok');
+is($configDB->fetchExportByID(2, 'id'), undef, 'export 2 should be gone');
+is($configDB->fetchExportByID(1)->{id}, 1, 'export 1 should still exist');
+is($configDB->fetchExportByID(3)->{id}, 3, 'export 3 should still exist');
+
+$configDB->disconnect();
+
diff --git a/src/config-db/t/12-system.t b/src/config-db/t/12-system.t
new file mode 100644
index 00000000..0c3a3042
--- /dev/null
+++ b/src/config-db/t/12-system.t
@@ -0,0 +1,360 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+ok(
+ my $system = $configDB->fetchSystemByFilter,
+ 'one system [default] should exist (scalar context)'
+);
+
+foreach my $requiredCol (qw(name export_id)) {
+ my $wrongSystem = {
+ 'name' => 'name',
+ 'export_id' => 1,
+ 'comment' => 'has column missing',
+ };
+ delete $wrongSystem->{$requiredCol};
+ ok(
+ ! eval { my $systemID = $configDB->addSystem($wrongSystem); },
+ "inserting a system without '$requiredCol' column should fail"
+ );
+}
+
+is(
+ my @systems = $configDB->fetchSystemByFilter, 1,
+ 'still just one system [default] should exist (array context)'
+);
+
+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,
+ 'first system has ID 1'
+);
+
+my $inSystem2 = {
+ 'name' => 'sys-2.0',
+ 'kernel' => 'vmlinuz',
+ 'export_id' => 1,
+ 'comment' => undef,
+};
+my $fullSystem = {
+ 'name' => 'sys-nr-3',
+ 'kernel' => 'vmlinuz-2.6.22.13-0.3-default',
+ 'export_id' => 3,
+ 'comment' => 'nuff said',
+ 'label' => 'BlingBling System - really kuul!',
+ 'attrs' => {
+ 'automnt_dir' => 'a',
+ 'automnt_src' => 'b',
+ 'country' => 'c',
+ 'hidden' => '1',
+ 'kernel_params' => 'debug=3 console=ttyS1',
+ 'ramfs_fsmods' => 'l',
+ 'ramfs_miscmods' => 'm',
+ 'ramfs_nicmods' => 'n',
+ 'scratch' => 'q',
+ 'start_atd' => 't',
+ 'start_cron' => 'u',
+ 'start_dreshal' => 'v',
+ 'start_ntp' => 'w',
+ 'start_nfsv4' => 'x',
+ 'start_snmp' => 'A',
+ 'start_sshd' => 'B',
+ 'timezone' => 'G',
+ },
+};
+ok(
+ my ($system2ID, $system3ID) = $configDB->addSystem([
+ $inSystem2, $fullSystem
+ ]),
+ 'add two more systems'
+);
+is($system2ID, 2, 'system 2 should have ID=2');
+is($system3ID, 3, 'system 3 should have ID=3');
+
+# fetch system 3 by id and check all values
+ok(my $system3 = $configDB->fetchSystemByID(3), 'fetch system 3');
+is($system3->{id}, '3', 'system 3 - id');
+is($system3->{name}, 'sys-nr-3', 'system 3 - name');
+is($system3->{kernel}, 'vmlinuz-2.6.22.13-0.3-default', 'system 3 - type');
+is($system3->{export_id}, '3', 'system 3 - export_id');
+is($system3->{comment}, 'nuff said', 'system 3 - comment');
+is($system3->{label}, 'BlingBling System - really kuul!', 'system 3 - label');
+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}->{hidden}, '1', 'system 3 - attr hidden');
+is($system3->{attrs}->{kernel_params}, 'debug=3 console=ttyS1', 'system 3 - attr kernel_params');
+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}->{scratch}, 'q', 'system 3 - attr scratch');
+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_snmp}, 'A', 'system 3 - attr start_snmp');
+is($system3->{attrs}->{start_sshd}, 'B', 'system 3 - attr start_sshd');
+is($system3->{attrs}->{timezone}, 'G', 'system 3 - attr timezone');
+is(keys %{$system3->{attrs}}, 17, '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(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(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(
+ my @systems3And1 = $configDB->fetchSystemByID([3, 1]),
+ 'fetch systems 3 & 1 by id'
+);
+is(@systems3And1, 2, 'should have got 2 systems');
+# now sort by ID and check if we have really got 3 and 1
+@systems3And1 = sort { $a->{id} cmp $b->{id} } @systems3And1;
+is($systems3And1[0]->{id}, 1, 'first id should be 1');
+is($systems3And1[1]->{id}, 3, 'second id should be 3');
+
+# fetching systems by id without giving any should yield undef
+is(
+ $configDB->fetchSystemByID(), undef,
+ 'fetch systems by id without giving any'
+);
+
+# fetching systems by filter without giving any should yield all of them
+ok(
+ @systems = $configDB->fetchSystemByFilter(),
+ 'fetch systems by filter without giving any'
+);
+is(@systems, 4, 'should have got all four systems');
+
+# fetch systems 1 & 2 by filter on export_id
+ok(
+ my @systems1And2 = $configDB->fetchSystemByFilter({ export_id => '1' }),
+ 'fetch systems 1 & 2 by filter on export_id'
+);
+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)
+ = $configDB->fetchSystemByFilter({ export_id => '1', id => 2 }),
+ 'fetching system with export_id=1 and id=2 should work'
+);
+is($system2->{name}, 'sys-2.0', 'should have got sys-2.0');
+is($system3, undef, 'should not get sys-nr-3');
+
+# try to fetch multiple occurrences of the same system, combined with
+# some unknown IDs
+ok(
+ my @systems1And3 = $configDB->fetchSystemByID([ 1, 21, 4-1, 1, 3, 1, 1 ]),
+ 'fetch a complex set of systems by ID'
+);
+is(@systems1And3, 2, 'should have got 2 systems');
+# now sort by ID and check if we have really got 1 and 3
+@systems1And3 = sort { $a->{id} cmp $b->{id} } @systems1And3;
+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,
+ comment => '',
+ }, '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_snmp => undef,
+ } ),
+ 'fetch systems 1 & 2 by filter on attribute start_snmp 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,
+ 'system with id -1 should not exist'
+);
+ok($configDB->fetchSystemByID(0), 'system with id 0 should exist');
+is(
+ $configDB->fetchSystemByID(1 << 31 + 1000), undef,
+ 'trying to fetch another unknown system'
+);
+
+# try to fetch a couple of non-existing systems by filter
+is(
+ $configDB->fetchSystemByFilter({ id => 4 }), undef,
+ 'fetching system with id=4 by filter should fail'
+);
+is(
+ $configDB->fetchSystemByFilter({ name => 'sys-1.x' }), undef,
+ 'fetching system with name="sys-1.x" should fail'
+);
+is(
+ $configDB->fetchSystemByFilter({ export_id => '2', id => 1 }), undef,
+ 'fetching system with export_id=2 and id=1 should fail'
+);
+
+# rename system 1 and then fetch it by its new name
+ok($configDB->changeSystem(1, { name => q{SYS-'1'} }), 'changing system 1');
+ok(
+ $system1 = $configDB->fetchSystemByFilter({ name => q{SYS-'1'} }),
+ 'fetching renamed system 1'
+);
+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');
+
+# adding attributes should work
+$inSystem1->{attrs}->{slxgrp} = 'slxgrp1';
+$inSystem1->{attrs}->{vmware} = 'yes';
+ok($configDB->changeSystem(1, $inSystem1), 'adding attrs to system 1');
+$system1 = $configDB->fetchSystemByID(1);
+is($system1->{attrs}->{slxgrp}, 'slxgrp1', 'attr slxgrp has correct value');
+is($system1->{attrs}->{vmware}, 'yes', 'attr vmware has correct value');
+
+# changing an attribute should work
+$inSystem1->{attrs}->{vmware} = 'no';
+ok($configDB->changeSystem(1, $inSystem1), 'changing vmware in system 1');
+$system1 = $configDB->fetchSystemByID(1);
+is($system1->{attrs}->{slxgrp}, 'slxgrp1', 'attr slxgrp has correct value');
+is($system1->{attrs}->{vmware}, 'no', 'attr vmware has correct value');
+
+# deleting an attribute should remove it
+delete $inSystem1->{attrs}->{slxgrp};
+ok($configDB->changeSystem(1, $inSystem1), 'changing slxgrp in system 1');
+$system1 = $configDB->fetchSystemByID(1);
+ok(!exists $system1->{attrs}->{slxgrp}, 'attr slxgrp should be gone');
+
+# undef'ing an attribute should remove it, too
+$inSystem1->{attrs}->{vmware} = undef;
+ok($configDB->changeSystem(1, $inSystem1), 'undefining vmware in system 1');
+$system1 = $configDB->fetchSystemByID(1);
+ok(!exists $system1->{attrs}->{vmware}, 'attr vmware should be gone');
+
+# changing a non-existing column should fail
+ok(
+ ! eval { $configDB->changeSystem(1, { xname => "xx" }) },
+ 'changing unknown colum should fail'
+);
+
+ok(! $configDB->changeSystem(1, { id => 23 }), 'changing id should fail');
+
+# now remove an system and check if that worked
+ok($configDB->removeSystem(2), 'removing system 2 should be ok');
+is($configDB->fetchSystemByID(2, 'id'), undef, 'system 2 should be gone');
+is($configDB->fetchSystemByID(1)->{id}, 1, 'system 1 should still exist');
+is($configDB->fetchSystemByID(3)->{id}, 3, 'system 3 should still exist');
+
+$configDB->disconnect();
+
diff --git a/src/config-db/t/13-client.t b/src/config-db/t/13-client.t
new file mode 100644
index 00000000..8be71518
--- /dev/null
+++ b/src/config-db/t/13-client.t
@@ -0,0 +1,320 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+ok(
+ my $client = $configDB->fetchClientByFilter,
+ 'one client [default] should exist (scalar context)'
+);
+
+foreach my $requiredCol (qw(name mac)) {
+ my $wrongClient = {
+ 'name' => 'name',
+ 'mac' => '01:02:03:04:05:06',
+ 'comment' => 'has column missing',
+ };
+ delete $wrongClient->{$requiredCol};
+ ok(
+ ! eval { my $clientID = $configDB->addClient($wrongClient); },
+ "inserting a client without '$requiredCol' column should fail"
+ );
+}
+
+is(
+ my @clients = $configDB->fetchClientByFilter, 1,
+ 'still just one client [default] should exist (array context)'
+);
+
+my $inClient1 = {
+ 'name' => 'cli-1',
+ 'mac' => '01:02:03:04:05:01',
+ 'comment' => '',
+ 'attrs' => {
+ 'start_snmp' => 'no',
+ 'start_sshd' => 'yes',
+ },
+};
+is(
+ my $client1ID = $configDB->addClient($inClient1), 1,
+ 'first client has ID 1'
+);
+
+my $inClient2 = {
+ 'name' => 'cli-2.0',
+ 'mac' => '01:02:03:04:05:02',
+ 'comment' => undef,
+ 'attrs' => {
+ 'boot_type' => 'etherboot',
+ 'unbootable' => 1,
+ }
+};
+my $fullClient = {
+ 'name' => 'cli-nr-3',
+ 'mac' => '01:02:03:04:05:03',
+ 'comment' => 'nuff said',
+ 'attrs' => {
+ 'automnt_dir' => 'a',
+ 'automnt_src' => 'b',
+ 'boot_type' => 'pxe',
+ 'country' => 'c',
+ 'kernel_params_client' => 'debug=3 console=ttyS1',
+ 'scratch' => 'q',
+ 'start_atd' => 't',
+ 'start_cron' => 'u',
+ 'start_dreshal' => 'v',
+ 'start_ntp' => 'w',
+ 'start_nfsv4' => 'x',
+ 'start_snmp' => 'A',
+ 'start_sshd' => 'B',
+ 'timezone' => 'G',
+ 'unbootable' => '0',
+ },
+};
+ok(
+ my ($client2ID, $client3ID) = $configDB->addClient([
+ $inClient2, $fullClient
+ ]),
+ 'add two more clients'
+);
+is($client2ID, 2, 'client 2 should have ID=2');
+is($client3ID, 3, 'client 3 should have ID=3');
+
+# fetch client 3 by id and check all values
+ok(my $client3 = $configDB->fetchClientByID(3), 'fetch client 3');
+is($client3->{id}, '3', 'client 3 - id');
+is($client3->{name}, 'cli-nr-3', 'client 3 - name');
+is($client3->{mac}, '01:02:03:04:05:03', 'client 3 - mac');
+is($client3->{comment}, 'nuff said', 'client 3 - comment');
+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}->{boot_type}, 'pxe', 'client 3 - attr boot_type');
+is($client3->{attrs}->{country}, 'c', 'client 3 - attr country');
+is($client3->{attrs}->{kernel_params_client}, 'debug=3 console=ttyS1', 'client 3 - attr kernel_params_client');
+is($client3->{attrs}->{scratch}, 'q', 'client 3 - attr scratch');
+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_snmp}, 'A', 'client 3 - attr start_snmp');
+is($client3->{attrs}->{start_sshd}, 'B', 'client 3 - attr start_sshd');
+is($client3->{attrs}->{timezone}, 'G', 'client 3 - attr timezone');
+is($client3->{attrs}->{unbootable}, '0', 'client 3 - attr unbootable');
+is(keys %{$client3->{attrs}}, 15, '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->{mac}, '01:02:03:04:05:02', 'client 2 - mac');
+is($client2->{comment}, undef, 'client 2 - comment');
+is(keys %{$client2->{attrs}}, 2, 'client 2 - attribute count');
+is($client2->{attrs}->{boot_type}, 'etherboot', 'client 2 - attr boot_type');
+is($client2->{attrs}->{unbootable}, '1', 'client 2 - attr unbootable');
+
+# fetch client 1 by filter on name and check all values
+ok(
+ my $client1 = $configDB->fetchClientByFilter({ name => 'cli-1' }),
+ 'fetch client 1 by filter on name'
+);
+is($client1->{id}, 1, 'client 1 - id');
+is($client1->{name}, 'cli-1', 'client 1 - name');
+is($client1->{mac}, '01:02:03:04:05:01', 'client 1 - mac');
+is($client1->{comment}, '', 'client 1 - comment');
+is(keys %{$client1->{attrs}}, 2, 'client 1 - attribute count');
+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(
+ my @clients3And1 = $configDB->fetchClientByID([3, 1]),
+ 'fetch clients 3 & 1 by id'
+);
+is(@clients3And1, 2, 'should have got 2 clients');
+# now sort by ID and check if we have really got 3 and 1
+@clients3And1 = sort { $a->{id} cmp $b->{id} } @clients3And1;
+is($clients3And1[0]->{id}, 1, 'first id should be 1');
+is($clients3And1[1]->{id}, 3, 'second id should be 3');
+
+# fetching clients by id without giving any should yield undef
+is(
+ $configDB->fetchClientByID(), undef,
+ 'fetch clients by id without giving any'
+);
+
+# fetching clients by filter without giving any should yield all of them
+ok(
+ @clients = $configDB->fetchClientByFilter(),
+ 'fetch clients by filter without giving any'
+);
+is(@clients, 4, 'should have got all four clients');
+
+# try to fetch multiple occurrences of the same client, combined with
+# some unknown IDs
+ok(
+ my @clients1And3 = $configDB->fetchClientByID([ 1, 21, 4-1, 1, 4, 1, 1 ]),
+ 'fetch a complex set of clients by ID'
+);
+is(@clients1And3, 2, 'should have got 2 clients');
+# now sort by ID and check if we have really got 1 and 3
+@clients1And3 = sort { $a->{id} cmp $b->{id} } @clients1And3;
+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(
+ my @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');
+
+is(
+ $configDB->fetchClientByFilter( {
+ comment => 'xxx',
+ }, 'id', {
+ start_snmp => 'no',
+ start_dreshal => undef,
+ } ),
+ undef,
+ 'mismatch client 1 by filter with incorrect value'
+);
+is(
+ $configDB->fetchClientByFilter( {
+ name => 'cli-1',
+ }, 'id', {
+ start_snmp => 'yes',
+ start_dreshal => 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_dreshal not existing
+ok(
+ my @clients01And2 = $configDB->fetchClientByFilter( {}, undef, {
+ start_dreshal => undef,
+ } ),
+ 'fetch clients 0,1 & 2 by filter on attribute start_dreshal 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,
+ 'client with id -1 should not exist'
+);
+ok($configDB->fetchClientByID(0), 'client with id 0 should exist');
+is(
+ $configDB->fetchClientByID(1 << 31 + 1000), undef,
+ 'trying to fetch another unknown client'
+);
+
+# try to fetch a couple of non-existing clients by filter
+is(
+ $configDB->fetchClientByFilter({ id => 4 }), undef,
+ 'fetching client with id=4 by filter should fail'
+);
+is(
+ $configDB->fetchClientByFilter({ name => 'cli-1.x' }), undef,
+ 'fetching client with name="cli-1.x" should fail'
+);
+is(
+ $configDB->fetchClientByFilter({ mac => '01:01:01:01:01:01', id => 1 }), undef,
+ 'fetching client with mac=01:01:01:01:01:01 and id=1 should fail'
+);
+
+# rename client 1 and then fetch it by its new name
+ok($configDB->changeClient(1, { name => q{CLI-'1'} }), 'changing client 1');
+ok(
+ $client1 = $configDB->fetchClientByFilter({ name => q{CLI-'1'} }),
+ 'fetching renamed client 1'
+);
+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');
+
+# adding attributes should work
+$inClient1->{attrs}->{slxgrp} = 'slxgrp1';
+$inClient1->{attrs}->{vmware} = 'yes';
+ok($configDB->changeClient(1, $inClient1), 'adding attrs to client 1');
+$client1 = $configDB->fetchClientByID(1);
+is($client1->{attrs}->{slxgrp}, 'slxgrp1', 'attr slxgrp has correct value');
+is($client1->{attrs}->{vmware}, 'yes', 'attr vmware has correct value');
+
+# changing an attribute should work
+$inClient1->{attrs}->{vmware} = 'no';
+ok($configDB->changeClient(1, $inClient1), 'changing vmware in client 1');
+$client1 = $configDB->fetchClientByID(1);
+is($client1->{attrs}->{slxgrp}, 'slxgrp1', 'attr slxgrp has correct value');
+is($client1->{attrs}->{vmware}, 'no', 'attr vmware has correct value');
+
+# deleting an attribute should remove it
+delete $inClient1->{attrs}->{slxgrp};
+ok($configDB->changeClient(1, $inClient1), 'changing slxgrp in client 1');
+$client1 = $configDB->fetchClientByID(1);
+ok(!exists $client1->{attrs}->{slxgrp}, 'attr slxgrp should be gone');
+
+# undef'ing an attribute should remove it, too
+$inClient1->{attrs}->{vmware} = undef;
+ok($configDB->changeClient(1, $inClient1), 'undefining vmware in client 1');
+$client1 = $configDB->fetchClientByID(1);
+ok(!exists $client1->{attrs}->{vmware}, 'attr vmware should be gone');
+
+# changing a non-existing column should fail
+ok(
+ ! eval { $configDB->changeClient(1, { xname => "xx" }) },
+ 'changing unknown colum should fail'
+);
+
+ok(! $configDB->changeClient(1, { id => 23 }), 'changing id should fail');
+
+# now remove an client and check if that worked
+ok($configDB->removeClient(2), 'removing client 2 should be ok');
+is($configDB->fetchClientByID(2, 'id'), undef, 'client 2 should be gone');
+is($configDB->fetchClientByID(1)->{id}, 1, 'client 1 should still exist');
+is($configDB->fetchClientByID(3)->{id}, 3, 'client 3 should still exist');
+
+$configDB->disconnect();
+
diff --git a/src/config-db/t/14-group.t b/src/config-db/t/14-group.t
new file mode 100644
index 00000000..5c5d0f81
--- /dev/null
+++ b/src/config-db/t/14-group.t
@@ -0,0 +1,384 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+is(
+ my $group = $configDB->fetchGroupByFilter, undef,
+ 'no group should exist (scalar context)'
+);
+
+foreach my $requiredCol (qw(name)) {
+ my $wrongGroup = {
+ 'name' => 'name',
+ 'priority' => 41,
+ 'comment' => 'has column missing',
+ };
+ delete $wrongGroup->{$requiredCol};
+ ok(
+ ! eval { my $groupID = $configDB->addGroup($wrongGroup); },
+ "inserting a group without '$requiredCol' column should fail"
+ );
+}
+
+is(
+ my @groups = $configDB->fetchGroupByFilter, 0,
+ 'still no group should exist (array context)'
+);
+
+my $inGroup1 = {
+ 'name' => 'grp-1',
+ 'comment' => '',
+ 'attrs' => {
+ 'slxgrp' => 'slxgrp',
+ 'start_snmp' => 'no',
+ 'start_sshd' => 'yes',
+ },
+};
+is(
+ my $group1ID = $configDB->addGroup($inGroup1), 1,
+ 'first group has ID 1'
+);
+
+my $inGroup2 = {
+ 'name' => 'grp-2.0',
+ 'priority' => 30,
+ 'comment' => undef,
+};
+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([
+ $inGroup2, $fullGroup
+ ]),
+ 'add two more groups'
+);
+is($group2ID, 2, 'group 2 should have ID=2');
+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->{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(
+ my $group2 = $configDB->fetchGroupByFilter({ id => 2 }),
+ 'fetch group 2 by filter on id'
+);
+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(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(
+ my @groups3And1 = $configDB->fetchGroupByID([3, 1]),
+ 'fetch groups 3 & 1 by id'
+);
+is(@groups3And1, 2, 'should have got 2 groups');
+# now sort by ID and check if we have really got 3 and 1
+@groups3And1 = sort { $a->{id} cmp $b->{id} } @groups3And1;
+is($groups3And1[0]->{id}, 1, 'first id should be 1');
+is($groups3And1[1]->{id}, 3, 'second id should be 3');
+
+# fetching groups by id without giving any should yield undef
+is(
+ $configDB->fetchGroupByID(), undef,
+ 'fetch groups by id without giving any'
+);
+
+# fetching groups by filter without giving any should yield all of them
+ok(
+ @groups = $configDB->fetchGroupByFilter(),
+ 'fetch groups by filter without giving any'
+);
+is(@groups, 3, 'should have got all three groups');
+
+# fetch groups 1 & 2 by filter on priority
+ok(
+ my @groups1And3 = $configDB->fetchGroupByFilter({ priority => 50 }),
+ 'fetch groups 1 & 3 by filter on priority'
+);
+is(@groups1And3, 2, 'should have got 2 groups');
+# now sort by ID and check if we have really got 1 and 3
+@groups1And3 = sort { $a->{id} cmp $b->{id} } @groups1And3;
+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)
+ = $configDB->fetchGroupByFilter({ priority => '50', id => 1 }),
+ 'fetching group with priority=50 and id=1 should work'
+);
+is($group1->{name}, 'grp-1', 'should have got grp-1');
+is($group3, undef, 'should not get grp-nr-3');
+
+# try to fetch multiple occurrences of the same group, combined with
+# some unknown IDs
+ok(
+ @groups1And3 = $configDB->fetchGroupByID([ 1, 21, 4-1, 1, 4, 1, 1 ]),
+ 'fetch a complex set of groups by ID'
+);
+is(@groups1And3, 2, 'should have got 2 groups');
+# now sort by ID and check if we have really got 1 and 3
+@groups1And3 = sort { $a->{id} cmp $b->{id} } @groups1And3;
+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');
+is(
+ $configDB->fetchGroupByID(1 << 31 + 1000), undef,
+ 'trying to fetch another unknown group'
+);
+
+# try to fetch a couple of non-existing groups by filter
+is(
+ $configDB->fetchGroupByFilter({ id => 4 }), undef,
+ 'fetching group with id=4 by filter should fail'
+);
+is(
+ $configDB->fetchGroupByFilter({ name => 'grp-1.x' }), undef,
+ 'fetching group with name="grp-1.x" should fail'
+);
+is(
+ $configDB->fetchGroupByFilter({ priority => '22', id => 1 }), undef,
+ 'fetching group with priority=22 and id=1 should fail'
+);
+
+# rename group 1 and then fetch it by its new name
+ok($configDB->changeGroup(1, { name => q{GRP-'1'} }), 'changing group 1');
+ok(
+ $group1 = $configDB->fetchGroupByFilter({ name => q{GRP-'1'} }),
+ 'fetching renamed group 1'
+);
+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');
+
+# adding attributes should work
+$inGroup1->{attrs}->{slxgrp} = 'slxgrp1';
+$inGroup1->{attrs}->{vmware} = 'yes';
+ok($configDB->changeGroup(1, $inGroup1), 'adding attrs to group 1');
+$group1 = $configDB->fetchGroupByID(1);
+is($group1->{attrs}->{slxgrp}, 'slxgrp1', 'attr slxgrp has correct value');
+is($group1->{attrs}->{vmware}, 'yes', 'attr vmware has correct value');
+
+# changing an attribute should work
+$inGroup1->{attrs}->{vmware} = 'no';
+ok($configDB->changeGroup(1, $inGroup1), 'changing vmware in group 1');
+$group1 = $configDB->fetchGroupByID(1);
+is($group1->{attrs}->{slxgrp}, 'slxgrp1', 'attr slxgrp has correct value');
+is($group1->{attrs}->{vmware}, 'no', 'attr vmware has correct value');
+
+# deleting an attribute should remove it
+delete $inGroup1->{attrs}->{slxgrp};
+ok($configDB->changeGroup(1, $inGroup1), 'changing slxgrp in group 1');
+$group1 = $configDB->fetchGroupByID(1);
+ok(!exists $group1->{attrs}->{slxgrp}, 'attr slxgrp should be gone');
+
+# undef'ing an attribute should remove it, too
+$inGroup1->{attrs}->{vmware} = undef;
+ok($configDB->changeGroup(1, $inGroup1), 'undefining vmware in group 1');
+$group1 = $configDB->fetchGroupByID(1);
+ok(!exists $group1->{attrs}->{vmware}, 'attr vmware should be gone');
+
+# changing a non-existing column should fail
+ok(
+ ! eval { $configDB->changeGroup(1, { xname => "xx" }) },
+ 'changing unknown colum should fail'
+);
+
+ok(! $configDB->changeGroup(1, { id => 23 }), 'changing id should fail');
+
+# now remove an group and check if that worked
+ok($configDB->removeGroup(2), 'removing group 2 should be ok');
+is($configDB->fetchGroupByID(2, 'id'), undef, 'group 2 should be gone');
+is($configDB->fetchGroupByID(1)->{id}, 1, 'group 1 should still exist');
+is($configDB->fetchGroupByID(3)->{id}, 3, 'group 3 should still exist');
+
+$configDB->disconnect();
+
diff --git a/src/config-db/t/15-global_info.t b/src/config-db/t/15-global_info.t
new file mode 100644
index 00000000..8f2f8cf1
--- /dev/null
+++ b/src/config-db/t/15-global_info.t
@@ -0,0 +1,43 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+# fetch global-info 'next-nbd-server-port'
+ok(
+ my $globalInfo = $configDB->fetchGlobalInfo('next-nbd-server-port'),
+ 'fetch global-info'
+);
+is($globalInfo, '5000', 'global-info - value');
+
+# try to fetch a couple of non-existing global-infos
+is(
+ $configDB->fetchGlobalInfo(-1), undef,
+ 'global-info with id -1 should not exist'
+);
+is($configDB->fetchGlobalInfo('xxx'), undef,
+ 'global-info with id xxx should not exist');
+
+# change value of global-info and then fetch and check the new value
+ok($configDB->changeGlobalInfo('next-nbd-server-port', '5050'), 'changing global-info');
+is(
+ $configDB->fetchGlobalInfo('next-nbd-server-port'), '5050',
+ 'fetching changed global-info'
+);
+
+# changing a non-existing global-info should fail
+ok(
+ ! eval { $configDB->changeGlobalInfo('xxx', 'new-value') },
+ 'changing unknown global-info should fail'
+);
+
+$configDB->disconnect();
+
diff --git a/src/config-db/t/20-client_system_ref.t b/src/config-db/t/20-client_system_ref.t
new file mode 100644
index 00000000..93b86950
--- /dev/null
+++ b/src/config-db/t/20-client_system_ref.t
@@ -0,0 +1,208 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+# fetch clients & systems
+my @clients = sort { $a->{id} <=> $b->{id} } $configDB->fetchClientByFilter();
+is(@clients, 3, 'should have got 3 clients (default, 1 and 3)');
+my $defaultClient = shift @clients;
+my $client1 = shift @clients;
+my $client3 = shift @clients;
+
+my @systems = sort { $a->{id} <=> $b->{id} } $configDB->fetchSystemByFilter();
+is(@systems, 3, 'should have got 3 systems (default, 1 and 3)');
+my $defaultSystem = shift @systems;
+my $system1 = shift @systems;
+my $system3 = shift @systems;
+
+foreach my $client ($defaultClient, $client1, $client3) {
+ is(
+ my @systemIDs = $configDB->fetchSystemIDsOfClient($client->{id}),
+ 0, "client $client->{id} has no system-IDs yet"
+ );
+}
+
+foreach my $system ($defaultSystem, $system1, $system3) {
+ is(
+ my @clientIDs = $configDB->fetchClientIDsOfSystem($system->{id}),
+ 0, "system $system->{id} has no client-IDs yet"
+ );
+}
+
+ok(
+ $configDB->addSystemIDsToClient(1, [3]),
+ 'system-ID 3 has been associated to client 1'
+);
+is(
+ my @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)),
+ 0, "default client should have no system-ID"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)),
+ 1, "client 1 should have one system-ID"
+);
+is($systemIDs[0], 3, "first system of client 1 should have ID 3");
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)),
+ 0, "client 3 should have no system-ID"
+);
+is(
+ my @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)),
+ 0, "default system should have no client-IDs"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)),
+ 0, "system 1 should have no client-IDs"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)),
+ 1, "system 3 should have one client-ID"
+);
+is($clientIDs[0], 1, "first client of system 3 should have ID 1");
+
+ok(
+ $configDB->addSystemIDsToClient(3, [1,3,3,1,3]),
+ 'system-IDs 1 and 3 have been associated to client 3'
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)),
+ 0, "default client should have no system-IDs"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)),
+ 1, "client 1 should have one system-ID"
+);
+is($systemIDs[0], 3, "first system of client 1 should have ID 3");
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)),
+ 2, "client 3 should have two system-IDs"
+);
+is($systemIDs[0], 1, "first system of client 3 should have ID 1");
+is($systemIDs[1], 3, "second system of client 3 should have ID 3");
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)),
+ 0, "default system should have no client-ID"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)),
+ 1, "system 1 should have one client-ID"
+);
+is($clientIDs[0], 3, "first client of system 1 should have ID 3");
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)),
+ 2, "system 3 should have two client-IDs"
+);
+is($clientIDs[0], 1, "first client of system 3 should have ID 1");
+is($clientIDs[1], 3, "second client of system 3 should have ID 3");
+
+ok(
+ $configDB->setClientIDsOfSystem(3, []),
+ 'client-IDs of system 3 have been set to empty array'
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)),
+ 0, "system 3 should have no client-IDs"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)),
+ 0, "client 1 should have no system-IDs"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)),
+ 1, "client 3 should have one system-ID"
+);
+is($systemIDs[0], 1, "first system of client 3 should have ID 1");
+
+ok(
+ $configDB->addSystemIDsToClient(1, [0]),
+ 'associating the default system should have no effect'
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)),
+ 0, "client 1 should still have no system-ID"
+);
+
+ok(
+ $configDB->removeClientIDsFromSystem(1, [1]),
+ 'removing an unassociated client-ID should have no effect'
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)),
+ 1, "system 1 should have one client-ID"
+);
+ok(
+ $configDB->removeClientIDsFromSystem(1, [3]),
+ 'removing an associated client-ID should work'
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)),
+ 0, "system 1 should have no more client-ID"
+);
+
+$configDB->addSystem({
+ 'name' => 'sys-4',
+ 'export_id' => 1,
+ 'comment' => 'shortlived',
+});
+ok(
+ $configDB->addClientIDsToSystem(4, [0]),
+ 'default client has been associated to system 4'
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(0)),
+ 1, "default client should have one system-ID"
+);
+is($systemIDs[0], 4, "first system of default client should have ID 4");
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(1)),
+ 0, "client 1 should have no system-ID"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfClient(3)),
+ 0, "client 3 should have no system-ID"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(0)),
+ 0, "default system should have no client-IDs"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(1)),
+ 0, "system 1 should have no client-ID"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(3)),
+ 0, "system 3 should have no client-IDs"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfSystem(4)),
+ 1, "system 4 should have one client-ID"
+);
+is($clientIDs[0], 0, "first client of system 4 should have ID 0");
+
+ok(
+ $configDB->removeSystemIDsFromClient(0, [6]),
+ 'removing an unassociated system-ID should have no effect'
+);
+is(
+ @clientIDs = sort($configDB->fetchSystemIDsOfClient(0)),
+ 1, "default client should have one system-ID"
+);
+ok(
+ $configDB->removeSystem(4),
+ 'removing a system should drop client associations, too'
+);
+is(
+ @clientIDs = sort($configDB->fetchSystemIDsOfClient(0)),
+ 0, "default client should have no more system-ID"
+);
+
+$configDB->disconnect();
diff --git a/src/config-db/t/21-group_system_ref.t b/src/config-db/t/21-group_system_ref.t
new file mode 100644
index 00000000..b643f7e0
--- /dev/null
+++ b/src/config-db/t/21-group_system_ref.t
@@ -0,0 +1,195 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+# fetch groups & systems
+my @groups = sort { $a->{id} <=> $b->{id} } $configDB->fetchGroupByFilter();
+is(@groups, 2, 'should have got 2 groups (1 and 3)');
+my $group1 = shift @groups;
+my $group3 = shift @groups;
+
+my @systems = sort { $a->{id} <=> $b->{id} } $configDB->fetchSystemByFilter();
+is(@systems, 3, 'should have got 3 systems (default, 1 and 3)');
+my $defaultSystem = shift @systems;
+my $system1 = shift @systems;
+my $system3 = shift @systems;
+
+foreach my $group ($group1, $group3) {
+ is(
+ my @systemIDs = $configDB->fetchSystemIDsOfGroup($group->{id}),
+ 0, "group $group->{id} has no system-IDs yet"
+ );
+}
+
+foreach my $system ($defaultSystem, $system1, $system3) {
+ is(
+ my @groupIDs = $configDB->fetchGroupIDsOfSystem($system->{id}),
+ 0, "system $system->{id} has no group-IDs yet"
+ );
+}
+
+ok(
+ $configDB->addSystemIDsToGroup(1, [3]),
+ 'system-ID 3 has been associated to group 1'
+);
+is(
+ 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");
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)),
+ 0, "group 3 should have no system-ID"
+);
+is(
+ my @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)),
+ 0, "default system should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)),
+ 0, "system 1 should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)),
+ 1, "system 3 should have one group-ID"
+);
+is($groupIDs[0], 1, "first group of system 3 should have ID 1");
+
+ok(
+ $configDB->addSystemIDsToGroup(3, [1,3,3,1,3]),
+ 'system-IDs 1 and 3 have been associated to group 3'
+);
+is(
+ @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");
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)),
+ 2, "group 3 should have two system-IDs"
+);
+is($systemIDs[0], 1, "first system of group 3 should have ID 1");
+is($systemIDs[1], 3, "second system of group 3 should have ID 3");
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)),
+ 0, "default system should have no group-ID"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)),
+ 1, "system 1 should have one group-ID"
+);
+is($groupIDs[0], 3, "first group of system 1 should have ID 3");
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)),
+ 2, "system 3 should have two group-IDs"
+);
+is($groupIDs[0], 1, "first group of system 3 should have ID 1");
+is($groupIDs[1], 3, "second group of system 3 should have ID 3");
+
+ok(
+ $configDB->setGroupIDsOfSystem(3, []),
+ 'group-IDs of system 3 have been set to empty array'
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)),
+ 0, "system 3 should have no group-IDs"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)),
+ 0, "group 1 should have no more system-IDs"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)),
+ 1, "group 3 should have one system-ID"
+);
+is($systemIDs[0], 1, "first system of group 3 should have ID 1");
+
+ok(
+ $configDB->addSystemIDsToGroup(1, [0]),
+ 'associating the default system should have no effect'
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)),
+ 0, "group 1 should still have no system-ID"
+);
+
+ok(
+ $configDB->removeGroupIDsFromSystem(1, [1]),
+ 'removing an unassociated group-ID should have no effect'
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)),
+ 1, "system 1 should have one group-ID"
+);
+ok(
+ $configDB->removeGroupIDsFromSystem(1, [3]),
+ 'removing an associated group-ID should work'
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)),
+ 0, "system 1 should have no more group-ID"
+);
+
+$configDB->addSystem({
+ 'name' => 'sys-5',
+ 'export_id' => 1,
+ 'comment' => 'shortlived',
+});
+ok(
+ $configDB->addGroupIDsToSystem(5, [3]),
+ 'default group has been associated to system 5'
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(1)),
+ 0, "group 1 should have no system-ID"
+);
+is(
+ @systemIDs = sort($configDB->fetchSystemIDsOfGroup(3)),
+ 1, "group 3 should have no system-ID"
+);
+is($systemIDs[0], 5, "first system of group 3 should have ID 5");
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(0)),
+ 0, "default system should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(1)),
+ 0, "system 1 should have no group-ID"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(3)),
+ 0, "system 3 should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfSystem(5)),
+ 1, "system 5 should have one group-ID"
+);
+is($groupIDs[0], 3, "first group of system 5 should have ID 3");
+
+ok(
+ $configDB->removeSystemIDsFromGroup(3, [6]),
+ 'removing an unassociated system-ID should have no effect'
+);
+is(
+ @groupIDs = sort($configDB->fetchSystemIDsOfGroup(3)),
+ 1, "group 3 should have one system-ID"
+);
+ok(
+ $configDB->removeSystem(5),
+ 'removing a system should drop group associations, too'
+);
+is(
+ @groupIDs = sort($configDB->fetchSystemIDsOfGroup(3)),
+ 0, "group 3 should have no more system-ID"
+);
+
+$configDB->disconnect();
diff --git a/src/config-db/t/22-group_client_ref.t b/src/config-db/t/22-group_client_ref.t
new file mode 100644
index 00000000..ff9d6ca7
--- /dev/null
+++ b/src/config-db/t/22-group_client_ref.t
@@ -0,0 +1,186 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+# fetch groups & clients
+my @groups = sort { $a->{id} <=> $b->{id} } $configDB->fetchGroupByFilter();
+is(@groups, 2, 'should have got 2 groups (1 and 3)');
+my $group1 = shift @groups;
+my $group3 = shift @groups;
+
+my @clients = sort { $a->{id} <=> $b->{id} } $configDB->fetchClientByFilter();
+is(@clients, 3, 'should have got 3 clients (default, 1 and 3)');
+my $defaultClient = shift @clients;
+my $client1 = shift @clients;
+my $client3 = shift @clients;
+
+foreach my $group ($group1, $group3) {
+ is(
+ my @clientIDs = $configDB->fetchClientIDsOfGroup($group->{id}),
+ 0, "group $group->{id} has no client-IDs yet"
+ );
+}
+
+foreach my $client ($defaultClient, $client1, $client3) {
+ is(
+ my @groupIDs = $configDB->fetchGroupIDsOfClient($client->{id}),
+ 0, "client $client->{id} has no group-IDs yet"
+ );
+}
+
+ok(
+ $configDB->addClientIDsToGroup(1, [3]),
+ 'client-ID 3 has been associated to group 1'
+);
+is(
+ 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");
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)),
+ 0, "group 3 should have no client-ID"
+);
+is(
+ my @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)),
+ 0, "default client should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)),
+ 0, "client 1 should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)),
+ 1, "client 3 should have one group-ID"
+);
+is($groupIDs[0], 1, "first group of client 3 should have ID 1");
+
+ok(
+ $configDB->addClientIDsToGroup(3, [1,3,3,1,3]),
+ 'client-IDs 1 and 3 have been associated to group 3'
+);
+is(
+ @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");
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)),
+ 2, "group 3 should have two client-IDs"
+);
+is($clientIDs[0], 1, "first client of group 3 should have ID 1");
+is($clientIDs[1], 3, "second client of group 3 should have ID 3");
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)),
+ 0, "default client should have no group-ID"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)),
+ 1, "client 1 should have one group-ID"
+);
+is($groupIDs[0], 3, "first group of client 1 should have ID 3");
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)),
+ 2, "client 3 should have two group-IDs"
+);
+is($groupIDs[0], 1, "first group of client 3 should have ID 1");
+is($groupIDs[1], 3, "second group of client 3 should have ID 3");
+
+ok(
+ $configDB->setGroupIDsOfClient(3, []),
+ 'group-IDs of client 3 have been set to empty array'
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)),
+ 0, "client 3 should have no group-IDs"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)),
+ 0, "group 1 should have no more client-IDs"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)),
+ 1, "group 3 should have one client-ID"
+);
+is($clientIDs[0], 1, "first client of group 3 should have ID 1");
+
+ok(
+ $configDB->removeGroupIDsFromClient(1, [1]),
+ 'removing an unassociated group-ID should have no effect'
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)),
+ 1, "client 1 should have one group-ID"
+);
+ok(
+ $configDB->removeGroupIDsFromClient(1, [3]),
+ 'removing an associated group-ID should work'
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)),
+ 0, "client 1 should have no more group-ID"
+);
+
+$configDB->addClient({
+ 'name' => 'cli-4',
+ 'mac' => '01:01:01:02:02:02',
+ 'comment' => 'shortlived',
+});
+ok(
+ $configDB->addGroupIDsToClient(4, [3]),
+ 'default group has been associated to client 4'
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfGroup(1)),
+ 0, "group 1 should have no client-ID"
+);
+is(
+ @clientIDs = sort($configDB->fetchClientIDsOfGroup(3)),
+ 1, "group 3 should have one client-ID"
+);
+is($clientIDs[0], 4, "first client of group 3 should have ID 1");
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(0)),
+ 0, "default client should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(1)),
+ 0, "client 1 should have no group-ID"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(3)),
+ 0, "client 3 should have no group-IDs"
+);
+is(
+ @groupIDs = sort($configDB->fetchGroupIDsOfClient(4)),
+ 1, "client 4 should have one group-ID"
+);
+is($groupIDs[0], 3, "first group of client 4 should have ID 3");
+
+ok(
+ $configDB->removeClientIDsFromGroup(3, [6]),
+ 'removing an unassociated client-ID should have no effect'
+);
+is(
+ @groupIDs = sort($configDB->fetchClientIDsOfGroup(3)),
+ 1, "group 3 should have one client-ID"
+);
+ok(
+ $configDB->removeClient(4),
+ 'removing a client should drop group associations, too'
+);
+is(
+ @groupIDs = sort($configDB->fetchClientIDsOfGroup(3)),
+ 0, "group 3 should have no more client-ID"
+);
+
+$configDB->disconnect();
diff --git a/src/config-db/t/25-attributes.t b/src/config-db/t/25-attributes.t
new file mode 100644
index 00000000..9662684c
--- /dev/null
+++ b/src/config-db/t/25-attributes.t
@@ -0,0 +1,677 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+use Clone qw(clone);
+
+# basic init
+use OpenSLX::ConfigDB qw(:support);
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+my $defaultAttrs = { # mostly copied from DBSchema
+ 'ramfs_fsmods' => undef,
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => 'forcedeth e1000 e100 tg3 via-rhine r8169 pcnet32',
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => undef,
+ 'slxgrp' => undef,
+ '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, { attrs => $defaultAttrs } ),
+ 'attributes of default system have been set'
+);
+my $defaultSystem = $configDB->fetchSystemByID(0);
+
+my $system1 = $configDB->fetchSystemByID(1);
+my $sys1Attrs = {
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+ 'start_x' => 'no',
+ 'start_xdmcp' => '',
+};
+ok(
+ $configDB->changeSystem(1, { attrs => $sys1Attrs } ),
+ 'attributes of system 1 have been set'
+);
+
+my $system3 = $configDB->fetchSystemByID(3);
+my $sys3Attrs = {
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+
+ '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, { 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 ;-)
+ 'timezone' => 'Europe/London',
+ # pretend we wanted to activate snmp globally (e.g. for testing)
+ 'start_snmp' => 'yes',
+};
+ok(
+ $configDB->changeClient(0, { attrs => $defaultClientAttrs } ),
+ 'attributes of default client have been set'
+);
+
+# check merging of default attributes, the order should be:
+# default system attributes overruled by system attributes overruled by
+# default client attributes:
+my $shouldBeAttrs1 = {
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => undef,
+ 'slxgrp' => undef,
+ '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(
+ $configDB->mergeDefaultAttributesIntoSystem($mergedSystem1),
+ 'merging default attributes into system 1'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedSystem1->{attrs}->{$key}, $shouldBeAttrs1->{$key},
+ "checking merged attribute $key for system 1"
+ );
+}
+
+# check merging code for completeness (using all attributes):
+my $shouldBeAttrs3 = {
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+
+ '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(
+ $configDB->mergeDefaultAttributesIntoSystem($mergedSystem3),
+ 'merging default attributes into system 3'
+);
+foreach my $key (sort keys %$shouldBeAttrs3) {
+ is(
+ $mergedSystem3->{attrs}->{$key}, $shouldBeAttrs3->{$key},
+ "checking merged attribute $key for system 3"
+ );
+}
+
+# setup client / group relations
+my $group1 = $configDB->fetchGroupByID(1);
+my $group1Attrs = {
+ 'priority' => '50',
+ # this group of clients is connected via underwater cable ...
+ 'timezone' => 'America/New_York',
+ # ... and use a local scratch partition
+ 'scratch' => '/dev/sdd1',
+ # the following should be a noop (as that attribute is system-specific)
+# 'ramfs_nicmods' => 'e1000',
+};
+ok(
+ $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
+ 'scratch' => '/dev/hdd1',
+ 'vmware' => 'yes',
+};
+ok(
+ $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
+ 'scratch' => '/dev/sdx3',
+};
+ok(
+ $configDB->changeClient(1, { attrs => $client1Attrs } ),
+ 'attributes of client 1 have been set'
+);
+ok(
+ $configDB->setGroupIDsOfClient(1, [1]),
+ 'group-IDs of client 1 have been set'
+);
+ok(
+ $configDB->setGroupIDsOfClient(3, []),
+ 'group-IDs of client 3 have been set'
+);
+
+# check merging of attributes into client, the order should be:
+# default client attributes overruled by group attributes (ordered by priority)
+# overruled by specific client attributes:
+$shouldBeAttrs1 = {
+ 'ramfs_fsmods' => undef,
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => undef,
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => undef,
+ 'dm_allow_shutdown' => undef,
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => undef,
+ 'netbios_workgroup' => undef,
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => undef,
+ 'start_alsasound' => undef,
+ 'start_atd' => undef,
+ 'start_cron' => undef,
+ 'start_dreshal' => undef,
+ 'start_ntp' => undef,
+ 'start_nfsv4' => undef,
+ 'start_printer' => undef,
+ 'start_samba' => undef,
+ 'start_snmp' => 'yes',
+ 'start_sshd' => undef,
+ 'start_syslog' => undef,
+ 'start_x' => undef,
+ 'start_xdmcp' => undef,
+ 'tex_enable' => undef,
+ 'timezone' => 'America/New_York',
+ 'tvout' => undef,
+ 'vmware' => undef,
+};
+my $mergedClient1 = $configDB->fetchClientByID(1);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1),
+ 'merging default and group attributes into client 1'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient1->{attrs}->{$key}, $shouldBeAttrs1->{$key},
+ "checking merged attribute $key for client 1"
+ );
+}
+
+$shouldBeAttrs3 = {
+ 'ramfs_fsmods' => undef,
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => undef,
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => undef,
+ 'dm_allow_shutdown' => undef,
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => undef,
+ 'netbios_workgroup' => undef,
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => undef,
+ 'slxgrp' => undef,
+ 'start_alsasound' => undef,
+ 'start_atd' => undef,
+ 'start_cron' => undef,
+ 'start_dreshal' => undef,
+ 'start_ntp' => undef,
+ 'start_nfsv4' => undef,
+ 'start_printer' => undef,
+ 'start_samba' => undef,
+ 'start_snmp' => 'yes',
+ 'start_sshd' => undef,
+ 'start_syslog' => undef,
+ 'start_x' => undef,
+ 'start_xdmcp' => undef,
+ 'tex_enable' => undef,
+ 'timezone' => 'Europe/London',
+ 'tvout' => undef,
+ 'vmware' => undef,
+};
+
+# remove all attributes from client 3
+$configDB->changeClient(3, { attrs => {} } );
+
+my $mergedClient3 = $configDB->fetchClientByID(3);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3),
+ 'merging default and group attributes into client 3'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient3->{attrs}->{$key}, $shouldBeAttrs3->{$key},
+ "checking merged attribute $key for client 3"
+ );
+}
+
+# now associate default client with group 3 and try again
+ok(
+ $configDB->setGroupIDsOfClient(0, [3]),
+ 'group-IDs of default client have been set'
+);
+$shouldBeAttrs1 = {
+ 'ramfs_fsmods' => undef,
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => undef,
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => undef,
+ 'dm_allow_shutdown' => undef,
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => undef,
+ 'netbios_workgroup' => undef,
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => undef,
+ 'start_alsasound' => undef,
+ 'start_atd' => undef,
+ 'start_cron' => undef,
+ 'start_dreshal' => undef,
+ 'start_ntp' => undef,
+ 'start_nfsv4' => undef,
+ 'start_printer' => undef,
+ 'start_samba' => undef,
+ 'start_snmp' => 'yes',
+ 'start_sshd' => undef,
+ 'start_syslog' => undef,
+ 'start_x' => undef,
+ 'start_xdmcp' => undef,
+ 'tex_enable' => undef,
+ 'timezone' => 'America/New_York',
+ 'tvout' => undef,
+ 'vmware' => 'yes',
+};
+$mergedClient1 = $configDB->fetchClientByID(1);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient1),
+ 'merging default and group attributes into client 1'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient1->{attrs}->{$key}, $shouldBeAttrs1->{$key},
+ "checking merged attribute $key for client 1"
+ );
+}
+
+$shouldBeAttrs3 = {
+ 'ramfs_fsmods' => undef,
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => undef,
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => undef,
+ 'dm_allow_shutdown' => undef,
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => undef,
+ 'netbios_workgroup' => undef,
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => '/dev/hdd1',
+ 'slxgrp' => undef,
+ 'start_alsasound' => undef,
+ 'start_atd' => undef,
+ 'start_cron' => undef,
+ 'start_dreshal' => undef,
+ 'start_ntp' => undef,
+ 'start_nfsv4' => undef,
+ 'start_printer' => undef,
+ 'start_samba' => undef,
+ 'start_snmp' => 'yes',
+ 'start_sshd' => undef,
+ 'start_syslog' => undef,
+ 'start_x' => undef,
+ 'start_xdmcp' => undef,
+ 'tex_enable' => undef,
+ 'timezone' => 'Europe/London',
+ 'tvout' => undef,
+ 'vmware' => 'yes',
+};
+$mergedClient3 = $configDB->fetchClientByID(3);
+ok(
+ $configDB->mergeDefaultAndGroupAttributesIntoClient($mergedClient3),
+ 'merging default and group attributes into client 3'
+);
+foreach my $key (sort keys %$shouldBeAttrs1) {
+ is(
+ $mergedClient3->{attrs}->{$key}, $shouldBeAttrs3->{$key},
+ "checking merged attribute $key for client 3"
+ );
+}
+
+# finally we merge systems into clients and check the outcome of that
+my $fullMerge11 = clone($mergedClient1);
+ok(
+ mergeAttributes($fullMerge11, $mergedSystem1),
+ 'merging system 1 into client 1'
+);
+my $shouldBeAttrs11 = {
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => '/dev/sdx3',
+ 'slxgrp' => undef,
+ '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->{attrs}->{$key}, $shouldBeAttrs11->{$key},
+ "checking merged attribute $key for client 1 / system 1"
+ );
+}
+
+my $fullMerge31 = clone($mergedClient3);
+ok(
+ mergeAttributes($fullMerge31, $mergedSystem1),
+ 'merging system 1 into client 3'
+);
+my $shouldBeAttrs31 = {
+ 'ramfs_fsmods' => 'squashfs',
+ 'ramfs_miscmods' => undef,
+ 'ramfs_nicmods' => 'forcedeth e1000 r8169',
+
+ 'automnt_dir' => undef,
+ 'automnt_src' => undef,
+ 'country' => 'de',
+ 'dm_allow_shutdown' => 'user',
+ 'hw_graphic' => undef,
+ 'hw_monitor' => undef,
+ 'hw_mouse' => undef,
+ 'late_dm' => 'no',
+ 'netbios_workgroup' => 'slx-network',
+ 'nis_domain' => undef,
+ 'nis_servers' => undef,
+ 'sane_scanner' => undef,
+ 'scratch' => '/dev/hdd1',
+ 'slxgrp' => undef,
+ '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->{attrs}->{$key}, $shouldBeAttrs31->{$key},
+ "checking merged attribute $key for client 3 / system 1"
+ );
+}
+
+my $fullMerge13 = clone($mergedClient1);
+ok(
+ mergeAttributes($fullMerge13, $mergedSystem3),
+ 'merging system 3 into client 1'
+);
+my $shouldBeAttrs13 = {
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+
+ '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->{attrs}->{$key}, $shouldBeAttrs13->{$key},
+ "checking merged attribute $key for client 1 / system 3"
+ );
+}
+
+my $fullMerge33 = clone($mergedClient3);
+ok(
+ mergeAttributes($fullMerge33, $mergedSystem3),
+ 'merging system 3 into client 3'
+);
+my $shouldBeAttrs33 = {
+ 'ramfs_fsmods' => '-4',
+ 'ramfs_miscmods' => '-3',
+ 'ramfs_nicmods' => '-2',
+
+ '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->{attrs}->{$key}, $shouldBeAttrs33->{$key},
+ "checking merged attribute $key for client 3 / system 3"
+ );
+}
+
+$configDB->disconnect();
diff --git a/src/config-db/t/29-transaction.t b/src/config-db/t/29-transaction.t
new file mode 100644
index 00000000..1f1566bf
--- /dev/null
+++ b/src/config-db/t/29-transaction.t
@@ -0,0 +1,58 @@
+use Test::More qw(no_plan);
+
+use strict;
+use warnings;
+
+use lib '/opt/openslx/lib';
+
+# basic init
+use OpenSLX::ConfigDB;
+
+my $configDB = OpenSLX::ConfigDB->new;
+$configDB->connect();
+
+my @vendorOSes = $configDB->fetchVendorOSByFilter();
+my @exports = $configDB->fetchExportByFilter();
+my @systems = $configDB->fetchSystemByFilter();
+my @clients = $configDB->fetchClientByFilter();
+my @groups = $configDB->fetchGroupByFilter();
+
+ok($configDB->startTransaction(), 'starting a transaction');
+
+ok($configDB->emptyDatabase(), 'emptying the DB');
+
+ok($configDB->rollbackTransaction(), 'rolling back the transaction');
+
+my @vendorOSes2 = $configDB->fetchVendorOSByFilter();
+my @exports2 = $configDB->fetchExportByFilter();
+my @systems2 = $configDB->fetchSystemByFilter();
+my @clients2 = $configDB->fetchClientByFilter();
+my @groups2 = $configDB->fetchGroupByFilter();
+
+is(
+ scalar @vendorOSes2, scalar @vendorOSes, "should still have all vendor-OSes"
+);
+is(scalar @exports2, scalar @exports, "should still have all exports");
+is(scalar @systems2, scalar @systems, "should still have all systems");
+is(scalar @clients2, scalar @clients, "should still have all clients");
+is(scalar @groups2, scalar @groups, "should still have all groups");
+
+ok($configDB->startTransaction(), 'starting a transaction');
+
+ok($configDB->emptyDatabase(), 'emptying the DB');
+
+ok($configDB->commitTransaction(), 'committing the transaction');
+
+my @vendorOSes3 = $configDB->fetchVendorOSByFilter();
+my @exports3 = $configDB->fetchExportByFilter();
+my @systems3 = $configDB->fetchSystemByFilter();
+my @clients3 = $configDB->fetchClientByFilter();
+my @groups3 = $configDB->fetchGroupByFilter();
+
+is(scalar @vendorOSes3, 0, "should have no vendor-OSes");
+is(scalar @exports3, 0, "should have no exports");
+is(scalar @systems3, 1, "should have one system (default)");
+is(scalar @clients3, 1, "should have one client (default)");
+is(scalar @groups3, 0, "should have no groups");
+
+$configDB->disconnect();
diff --git a/src/config-db/t/run-all-tests.pl b/src/config-db/t/run-all-tests.pl
new file mode 100755
index 00000000..8fb351c7
--- /dev/null
+++ b/src/config-db/t/run-all-tests.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::Harness;
+
+# add the development paths to perl's search path for modules:
+use FindBin;
+use lib "$FindBin::RealBin/../";
+use lib "$FindBin::RealBin/../../lib";
+
+chdir "$FindBin::RealBin" or die "unable to chdir to $FindBin::RealBin! ($!)\n";
+
+use OpenSLX::Basics;
+
+use OpenSLX::MetaDB::SQLite;
+
+# make sure a specific test-db will be used
+$cmdlineConfig{'private-path'} = $ENV{SLX_PRIVATE_PATH} = '/tmp/slx-db-test';
+$cmdlineConfig{'db-name'} = $ENV{SLX_DB_NAME} = 'slx-test';
+$cmdlineConfig{'db-type'} = $ENV{SLX_DB_TYPE} = 'SQLite';
+
+openslxInit();
+
+$Test::Harness::Verbose = 1 if $openslxConfig{'log-level'};
+
+# remove the test-db if it already exists
+my $metaDB = OpenSLX::MetaDB::SQLite->new();
+if ($metaDB->databaseExists()) {
+ print "removing leftovers of slx-test-db\n";
+ $metaDB->dropDatabase();
+}
+runtests(glob("*.t"));
+
+$metaDB->dropDatabase();