From cd10098d0dfabb2bacf6b5f3dd8628fa6f26f244 Mon Sep 17 00:00:00 2001 From: Michal Rakowski Date: Wed, 14 Oct 2020 16:42:22 +0200 Subject: [PATCH] regress: Add synthetic test to check 'list object' filters --- regress/tests/plugin-objects-syntetic-test | 151 +++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100755 regress/tests/plugin-objects-syntetic-test diff --git a/regress/tests/plugin-objects-syntetic-test b/regress/tests/plugin-objects-syntetic-test new file mode 100755 index 000000000..c244061bf --- /dev/null +++ b/regress/tests/plugin-objects-syntetic-test @@ -0,0 +1,151 @@ +#!/bin/sh +# +# Copyright (C) 2000-2020 Kern Sibbald +# License: BSD 2-Clause; see file LICENSE-FOSS +# +# Test for proper filtering 'list object' commands. +# +TestName="plugin-object-syntetic-test" +. scripts/functions + +scripts/cleanup + +start_test + +cat <${cwd}/tmp/bconcmds +@output /dev/null +messages +@$out ${cwd}/tmp/log1.out +list objects +quit +EOF + +run_bacula + +objects_lines=`cat ${cwd}/tmp/log1.out | grep 'No results to list' | wc -l` +if [ ${objects_lines} -ne 1 ]; then + estat=1 + print_debug "Wrong plugin objects count found in output: ${objects_lines}, expected 2" +fi + +cat <${cwd}/tmp/bconcmds +sqlquery +INSERT INTO Object (JobId, Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) + VALUES (1, '/dummy/path2', 'file1', 'plugin1', 'Category_first', 'Type_first', 'objName1', 'objSource1', 'objUUID1', 1); +INSERT INTO Object (JobId, Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) + VALUES (2, '/dummy/path2', 'file2', 'plugin2', 'Category_second', 'Type_second', 'objName2', 'objSource2', 'objUUID2', 2); +INSERT INTO Object (JobId, Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) + VALUES (2, '/dummy/path2', 'file2', 'plugin2', 'Category_second','Type_second', 'objName2', 'objSource2', 'objUUID2', 2); +INSERT INTO Object (JobId, Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) + VALUES (3, '/dummy/path3', 'file3', 'plugin3', 'Category_third', 'Type_third', 'objName3', 'objSource3', 'objUUID3', 3); +INSERT INTO Object (JobId, Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) + VALUES (3, '/dummy/path3', 'file3', 'plugin3', 'Category_third', 'Type_third', 'objName3', 'objSource3', 'objUUID3', 3); +INSERT INTO Object (JobId, Path, Filename, PluginName, ObjectCategory, ObjectType, ObjectName, ObjectSource, ObjectUUID, ObjectSize) + VALUES (3, '/dummy/path3', 'file3', 'plugin3', 'Category_third', 'Type_third', 'objName3', 'objSource3', 'objUUID3', 3); +quit +EOF + +run_bconsole + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log2.out +list objects +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log2.out | grep 'Type*' | wc -l` +if [ ${objects_lines} -ne 6 ]; then + estat=1 + print_debug "Wrong plugin objects count found in output: ${objects_lines}, expected 6" +fi + +# Type filter +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log3.out +list objects type=Type_first +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log3.out | grep 'Type_first' | wc -l` +if [ ${objects_lines} -ne 2 ]; then + estat=1 + print_debug "Wrong 'Type_first' plugin objects count found in output: ${objects_lines}, expected 1" +fi + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log4.out +list objects type=Type_second +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log4.out | grep 'Type_second' | wc -l` +if [ ${objects_lines} -ne 3 ]; then + estat=1 + print_debug "Wrong 'Type_second' plugin objects count found in output: ${objects_lines}, expected 2" +fi + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log5.out +list objects type=Type_third +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log5.out | grep 'Type_third' | wc -l` +if [ ${objects_lines} -ne 4 ]; then + estat=1 + print_debug "Wrong 'Type_third' plugin objects count found in output: ${objects_lines}, expected 3" +fi + + +# JobId filter +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log6.out +list objects jobid=1 +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log6.out | grep 'Type_first' | wc -l` +if [ ${objects_lines} -ne 1 ]; then + estat=1 + print_debug "Wrong 'Type_first' plugin objects count found in output: ${objects_lines}, expected 1" +fi + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log7.out +list objects jobid=2 +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log7.out | grep 'Type_second' | wc -l` +if [ ${objects_lines} -ne 2 ]; then + estat=1 + print_debug "Wrong 'Type_second' plugin objects count found in output: ${objects_lines}, expected 2" +fi + +cat <${cwd}/tmp/bconcmds +@$out ${cwd}/tmp/log8.out +list objects jobid=3 +quit +EOF + +run_bconsole + +objects_lines=`cat ${cwd}/tmp/log8.out | grep 'Type_third' | wc -l` +if [ ${objects_lines} -ne 3 ]; then + estat=1 + print_debug "Wrong 'Type_third' plugin objects count found in output: ${objects_lines}, expected 3" +fi + +end_test -- 2.47.3