GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/upload_spooler_definition.cc
Date: 2024-04-28 02:33:07
Exec Total Coverage
Lines: 30 42 71.4%
Branches: 18 35 51.4%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #include "upload_spooler_definition.h"
6
7 #include <vector>
8
9 #include "util/logging.h"
10 #include "util/string.h"
11
12 namespace upload {
13
14 const char* SpoolerDefinition::kDriverNames[] =
15 {"S3", "local", "gw", "mock", "unknown"};
16
17 133 SpoolerDefinition::SpoolerDefinition(
18 const std::string& definition_string,
19 const shash::Algorithms hash_algorithm,
20 const zlib::Algorithms compression_algorithm,
21 const bool generate_legacy_bulk_chunks,
22 const bool use_file_chunking,
23 const size_t min_file_chunk_size,
24 const size_t avg_file_chunk_size,
25 const size_t max_file_chunk_size,
26 const std::string& session_token_file,
27 133 const std::string& key_file)
28 133 : driver_type(Unknown),
29 133 hash_algorithm(hash_algorithm),
30 133 compression_alg(compression_algorithm),
31 133 generate_legacy_bulk_chunks(generate_legacy_bulk_chunks),
32 133 use_file_chunking(use_file_chunking),
33 133 min_file_chunk_size(min_file_chunk_size),
34 133 avg_file_chunk_size(avg_file_chunk_size),
35 133 max_file_chunk_size(max_file_chunk_size),
36 133 number_of_concurrent_uploads(kDefaultMaxConcurrentUploads),
37 133 num_upload_tasks(kDefaultNumUploadTasks),
38
1/2
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
133 session_token_file(session_token_file),
39
1/2
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
133 key_file(key_file),
40 133 valid_(false) {
41 // check if given file chunking values are sane
42
4/6
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 129 times.
133 if (use_file_chunking && (min_file_chunk_size >= avg_file_chunk_size ||
43 avg_file_chunk_size >= max_file_chunk_size)) {
44 LogCvmfs(kLogSpooler, kLogStderr, "file chunk size values are not sane");
45 return;
46 }
47
48 // split the spooler driver definition into name and config part
49
1/2
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
133 std::vector<std::string> upstream = SplitString(definition_string, ',');
50
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 if (upstream.size() != 3) {
51 LogCvmfs(kLogSpooler, kLogStderr, "Invalid spooler driver");
52 return;
53 }
54
55 // recognize and configure the spooler driver
56
2/2
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 97 times.
133 if (upstream[0] == "local") {
57 36 driver_type = Local;
58
2/2
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 85 times.
97 } else if (upstream[0] == "S3") {
59 12 driver_type = S3;
60
2/2
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 81 times.
85 } else if (upstream[0] == "gw") {
61 4 driver_type = Gateway;
62
1/2
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
81 } else if (upstream[0] == "mock") {
63 81 driver_type = Mock; // for unit testing purpose only!
64 } else {
65 driver_type = Unknown;
66 LogCvmfs(kLogSpooler, kLogStderr, "unknown spooler driver: %s",
67 upstream[0].c_str());
68 return;
69 }
70
71 // save data
72
1/2
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 temporary_path = upstream[1];
73
1/2
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
133 spooler_configuration = upstream[2];
74 133 valid_ = true;
75
1/2
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
133 }
76
77 SpoolerDefinition SpoolerDefinition::Dup2DefaultCompression() const {
78 SpoolerDefinition result(*this);
79 result.compression_alg = zlib::kZlibDefault;
80 return result;
81 }
82
83 } // namespace upload
84