Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5a0325
commit 50c1fe3
Showing
5 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
core/src/tests/configs/pruning/bareos-dir.d/director/bareos-dir.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Director { | ||
Name = bareos-dir | ||
Password = "bareos" | ||
} |
7 changes: 7 additions & 0 deletions
7
core/src/tests/configs/pruning/bareos-dir.d/storage/File.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Storage { | ||
Name = File | ||
Address = localhost | ||
Password = "" | ||
Device = FileStorage | ||
Media Type = File | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
BAREOS® - Backup Archiving REcovery Open Sourced | ||
Copyright (C) 2022-2022 Bareos GmbH & Co. KG | ||
This program is Free Software; you can redistribute it and/or | ||
modify it under the terms of version three of the GNU Affero General Public | ||
License as published by the Free Software Foundation and included | ||
in the file LICENSE. | ||
This program is distributed in the hope that it will be useful, but | ||
WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
02110-1301, USA. | ||
*/ | ||
|
||
#include "testing_dir_common.h" | ||
|
||
#include "include/jcr.h" | ||
#include "dird/job.h" | ||
#include "dird/ua_prune.h" | ||
|
||
TEST(Pruning, ExcludeRunningJobsFromList) | ||
{ | ||
std::string path_to_config | ||
= std::string(RELATIVE_PROJECT_SOURCE_DIR "/configs/pruning/"); | ||
PConfigParser director_config(DirectorPrepareResources(path_to_config)); | ||
if (!director_config) { return; } | ||
|
||
JobControlRecord* jcr1 = directordaemon::NewDirectorJcr(); | ||
jcr1->JobId = 1; | ||
JobControlRecord* jcr2 = directordaemon::NewDirectorJcr(); | ||
jcr2->JobId = 2; | ||
JobControlRecord* jcr3 = directordaemon::NewDirectorJcr(); | ||
jcr3->JobId = 3; | ||
|
||
std::vector<JobId_t> pruninglist{1, 2, 3, 4, 5}; | ||
int NumJobsToBePruned | ||
= directordaemon::ExcludeRunningJobsFromList(pruninglist); | ||
|
||
EXPECT_EQ(NumJobsToBePruned, 2); | ||
EXPECT_EQ(pruninglist[0], 4); | ||
EXPECT_EQ(pruninglist[1], 5); | ||
} |