summaryrefslogtreecommitdiffstats
path: root/config-db/t
diff options
context:
space:
mode:
authorOliver Tappe2007-12-16 16:27:43 +0100
committerOliver Tappe2007-12-16 16:27:43 +0100
commit5ffdf45ad2ac31302cf3c4b3d6ecb27f4ffffe32 (patch)
treeb6c12674f8e7b559eaa76543d1850380f0bcba7c /config-db/t
parentRevert test commit. (diff)
downloadcore-5ffdf45ad2ac31302cf3c4b3d6ecb27f4ffffe32.tar.gz
core-5ffdf45ad2ac31302cf3c4b3d6ecb27f4ffffe32.tar.xz
core-5ffdf45ad2ac31302cf3c4b3d6ecb27f4ffffe32.zip
* completed regression tests for vendor-OSes
* added regression tests for exports, systems and clients * fixed several bugs found by these tests * cosmetical cleanups in ConfigDB.pm git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1431 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/t')
-rw-r--r--config-db/t/10-vendor-os.t17
-rw-r--r--config-db/t/11-export.t218
-rw-r--r--config-db/t/12-system.t221
-rw-r--r--config-db/t/13-client.t208
-rwxr-xr-xconfig-db/t/run-all-tests.pl4
5 files changed, 667 insertions, 1 deletions
diff --git a/config-db/t/10-vendor-os.t b/config-db/t/10-vendor-os.t
index 9f7c9f11..b0754be7 100644
--- a/config-db/t/10-vendor-os.t
+++ b/config-db/t/10-vendor-os.t
@@ -12,6 +12,15 @@ 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)'
@@ -173,7 +182,13 @@ ok(
'changing unknown colum should fail'
);
-ok($configDB->changeVendorOS(1, { id => 23 }), 'changing id should fail');
+ok(! $configDB->changeVendorOS(1, { id => 23 }), 'changing id should fail');
+
+# 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/config-db/t/11-export.t b/config-db/t/11-export.t
new file mode 100644
index 00000000..b122ffdd
--- /dev/null
+++ b/config-db/t/11-export.t
@@ -0,0 +1,218 @@
+use Test::More qw(no_plan);
+
+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)'
+);
+
+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');
+
+# 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 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/config-db/t/12-system.t b/config-db/t/12-system.t
new file mode 100644
index 00000000..ee908dba
--- /dev/null
+++ b/config-db/t/12-system.t
@@ -0,0 +1,221 @@
+use Test::More qw(no_plan);
+
+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' => '',
+};
+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!',
+ 'kernel_params' => 'debug=3 console=ttyS1',
+ 'hidden' => '1',
+ 'attr_ramfs_nicmods' => 'e1000 forcedeth',
+ 'attr_ramfs_fsmods' => 'squashfs',
+ 'attr_ramfs_miscmods' => 'tpm',
+ 'attr_ramfs_screen' => '1024x768',
+};
+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->{kernel_params}, 'debug=3 console=ttyS1', 'system 3 - kernel_params');
+is($system3->{hidden}, '1', 'system 3 - hidden');
+is($system3->{attr_ramfs_nicmods}, 'e1000 forcedeth', 'system 3 - attr_ramfs_nicmods');
+is($system3->{attr_ramfs_fsmods}, 'squashfs', 'system 3 - attr_ramfs_fsmods');
+is($system3->{attr_ramfs_miscmods}, 'tpm', 'system 3 - attr_ramfs_miscmods');
+is($system3->{attr_ramfs_screen}, '1024x768', 'system 3 - attr_ramfs_screen');
+
+# 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');
+
+# fetch system 1 by filter on name and check all values
+ok(
+ my $system1 = $configDB->fetchSystemByFilter({ name => 'sys-1' }),
+ 'fetch system 1 by filter on name'
+);
+is($system1->{id}, 1, 'system 1 - id');
+is($system1->{name}, 'sys-1', 'system 1 - name');
+is($system1->{export_id}, '1', 'system 1 - export_id');
+is($system1->{kernel}, 'vmlinuz', 'system 1 - kernel');
+is($system1->{comment}, '', 'system 1 - comment');
+is($system1->{label}, 'sys-1', 'system 1 - label');
+is($system1->{kernel_params}, undef, 'system 1 - kernel_params');
+is($system1->{hidden}, undef, 'system 1 - hidden');
+is($system1->{attr_ramfs_nicmods}, undef, 'system 1 - attr_ramfs_nicmods');
+is($system1->{attr_ramfs_fsmods}, undef, 'system 1 - attr_ramfs_fsmods');
+is($system1->{attr_ramfs_miscmods}, undef, 'system 1 - attr_ramfs_miscmods');
+is($system1->{attr_ramfs_screen}, undef, 'system 1 - attr_ramfs_screen');
+
+# 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');
+
+# 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 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/config-db/t/13-client.t b/config-db/t/13-client.t
new file mode 100644
index 00000000..ff41e49b
--- /dev/null
+++ b/config-db/t/13-client.t
@@ -0,0 +1,208 @@
+use Test::More qw(no_plan);
+
+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' => '',
+};
+is(
+ my $client1ID = $configDB->addClient($inClient1), 1,
+ 'first client has ID 1'
+);
+
+my $inClient2 = {
+ 'name' => 'cli-2.0',
+ 'unbootable' => 1,
+ 'mac' => '01:02:03:04:05:02',
+ 'comment' => undef,
+ 'boot_type' => 'etherboot',
+};
+my $fullClient = {
+ 'name' => 'cli-nr-3',
+ 'mac' => '01:02:03:04:05:03',
+ 'comment' => 'nuff said',
+ 'kernel_params' => 'debug=3 console=ttyS1',
+ 'unbootable' => '0',
+ 'boot_type' => 'pxe',
+};
+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->{boot_type}, 'pxe', 'client 3 - boot_type');
+is($client3->{kernel_params}, 'debug=3 console=ttyS1', 'client 3 - kernel_params');
+is($client3->{unbootable}, '0', 'client 3 - unbootable');
+
+# fetch client 2 by a filter on id and check all values
+ok(
+ my $client2 = $configDB->fetchClientByFilter({ id => 2 }),
+ 'fetch client 2 by filter on id'
+);
+is($client2->{id}, 2, 'client 2 - id');
+is($client2->{name}, 'cli-2.0', 'client 2 - name');
+is($client2->{unbootable}, '1', 'client 2 - unbootable');
+is($client2->{mac}, '01:02:03:04:05:02', 'client 2 - mac');
+is($client2->{comment}, undef, 'client 2 - comment');
+is($client2->{boot_type}, 'etherboot', 'client 2 - boot_type');
+
+# 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->{unbootable}, undef, 'client 1 - unbootable');
+is($client1->{comment}, '', 'client 1 - comment');
+is($client1->{boot_type}, 'pxe', 'client 1 - boot_type');
+is($client1->{kernel_params}, undef, 'client 1 - kernel_params');
+
+# 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');
+
+# fetch clients 1 & 2 by filter on boot_type
+ok(
+ my @clients1And3 = $configDB->fetchClientByFilter({ boot_type => 'pxe' }),
+ 'fetch clients 1 & 3 by filter on boot_type'
+);
+is(@clients1And3, 2, 'should have got 2 clients');
+# now sort by ID and check if we have really got 1 and 3
+@clients1And2 = 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');
+
+# try to fetch with multi-column filter
+ok(
+ ($client1, $client3)
+ = $configDB->fetchClientByFilter({ boot_type => 'pxe', id => 1 }),
+ 'fetching client with boot_type=pxe and id=1 should work'
+);
+is($client1->{name}, 'cli-1', 'should have got cli-1');
+is($client3, undef, 'should not get cli-nr-3');
+
+# 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');
+
+# 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 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/config-db/t/run-all-tests.pl b/config-db/t/run-all-tests.pl
index 6cebdac1..c082052d 100755
--- a/config-db/t/run-all-tests.pl
+++ b/config-db/t/run-all-tests.pl
@@ -10,6 +10,8 @@ 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;
@@ -21,6 +23,8 @@ $cmdlineConfig{'db-type'} = $ENV{SLX_DB_TYPE} = 'SQLite';
openslxInit();
+$Test::Harness::Verbose = 1 if $openslxConfig{'verbose-level'};
+
# remove the test-db if it already exists
my $metaDB = OpenSLX::MetaDB::SQLite->new();
if ($metaDB->databaseExists()) {