Skip to content

Commit 5811155

Browse files
committed
src/common/io_exerciser: Formatting improvements using clang format
Signed-off-by: Jon Bailey <[email protected]>
1 parent e2ef125 commit 5811155

19 files changed

+2990
-3957
lines changed

src/common/io_exerciser/DataGenerator.cc

Lines changed: 347 additions & 447 deletions
Large diffs are not rendered by default.

src/common/io_exerciser/DataGenerator.h

Lines changed: 129 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include <memory>
44
#include <random>
55

6-
#include "include/buffer.h"
76
#include "ObjectModel.h"
7+
#include "include/buffer.h"
88

99
/* Overview
1010
*
@@ -23,149 +23,139 @@
2323
*
2424
* class HeaderedSeededRandomGenerator
2525
* Inherits from SeededDataGenerator. Generates entirely random patterns
26-
* based on the seed retrieved by the model, however also appends a
26+
* based on the seed retrieved by the model, however also appends a
2727
* header to the start of each block. This generator also provides
2828
* a range of verbose debug options to help disagnose a miscompare
2929
* whenever it detects unexpected data.
3030
*/
3131

3232
namespace ceph {
33-
namespace io_exerciser {
34-
namespace data_generation {
35-
enum class GenerationType {
36-
SeededRandom,
37-
HeaderedSeededRandom
38-
// CompressedGenerator
39-
// MixedGenerator
40-
};
41-
42-
class DataGenerator {
43-
public:
44-
virtual ~DataGenerator() = default;
45-
static std::unique_ptr<DataGenerator>
46-
create_generator(GenerationType generatorType,
47-
const ObjectModel& model);
48-
virtual bufferlist generate_data(uint64_t length, uint64_t offset)=0;
49-
virtual bool validate(bufferlist& bufferlist, uint64_t offset,
50-
uint64_t length);
51-
52-
// Used for testing debug outputs from data generation
53-
virtual bufferlist generate_wrong_data(uint64_t offset, uint64_t length);
54-
55-
protected:
56-
const ObjectModel& m_model;
57-
58-
DataGenerator(const ObjectModel& model) : m_model(model) {}
59-
};
60-
61-
class SeededRandomGenerator : public DataGenerator
62-
{
63-
public:
64-
SeededRandomGenerator(const ObjectModel& model)
65-
: DataGenerator(model) {}
66-
67-
virtual bufferptr generate_block(uint64_t offset);
68-
virtual bufferlist generate_data(uint64_t length, uint64_t offset) override;
69-
virtual bufferptr generate_wrong_block(uint64_t offset);
70-
virtual bufferlist generate_wrong_data(uint64_t offset, uint64_t length) override;
71-
};
72-
73-
class HeaderedSeededRandomGenerator : public SeededRandomGenerator
74-
{
75-
public:
76-
HeaderedSeededRandomGenerator(const ObjectModel& model,
77-
std::optional<uint64_t> unique_run_id = std::nullopt);
78-
79-
bufferptr generate_block(uint64_t offset) override;
80-
bufferptr generate_wrong_block(uint64_t offset) override;
81-
bool validate(bufferlist& bufferlist, uint64_t offset,
82-
uint64_t length) override;
83-
84-
private:
85-
using UniqueIdBytes = uint64_t;
86-
using SeedBytes = int;
87-
using TimeBytes = uint64_t;
88-
89-
enum class ErrorType {
90-
RUN_ID_MISMATCH,
91-
SEED_MISMATCH,
92-
DATA_MISMATCH,
93-
DATA_NOT_FOUND,
94-
UNKNOWN
95-
};
96-
97-
constexpr uint8_t headerStart() const
98-
{ return 0; };
99-
constexpr uint8_t uniqueIdStart() const
100-
{ return headerStart(); };
101-
constexpr uint8_t uniqueIdLength() const
102-
{ return sizeof(UniqueIdBytes); };
103-
constexpr uint8_t seedStart() const
104-
{ return uniqueIdStart() + uniqueIdLength(); };
105-
constexpr uint8_t seedLength() const
106-
{ return sizeof(SeedBytes); };
107-
constexpr uint8_t timeStart() const
108-
{ return seedStart() + seedLength(); };
109-
constexpr uint8_t timeLength() const
110-
{ return sizeof(TimeBytes); };
111-
constexpr uint8_t timeEnd() const
112-
{ return timeStart() + timeLength(); };
113-
constexpr uint8_t headerLength() const
114-
{ return uniqueIdLength() + seedLength() + timeLength(); };
115-
constexpr uint8_t bodyStart() const
116-
{ return headerStart() + headerLength(); };
117-
118-
const UniqueIdBytes readUniqueRunId(uint64_t block_offset,
119-
const bufferlist& bufferlist);
120-
const SeedBytes readSeed(uint64_t block_offset,
121-
const bufferlist& bufferlist);
122-
const TimeBytes readDateTime(uint64_t block_offset,
33+
namespace io_exerciser {
34+
namespace data_generation {
35+
enum class GenerationType {
36+
SeededRandom,
37+
HeaderedSeededRandom
38+
// CompressedGenerator
39+
// MixedGenerator
40+
};
41+
42+
class DataGenerator {
43+
public:
44+
virtual ~DataGenerator() = default;
45+
static std::unique_ptr<DataGenerator> create_generator(
46+
GenerationType generatorType, const ObjectModel& model);
47+
virtual bufferlist generate_data(uint64_t length, uint64_t offset) = 0;
48+
virtual bool validate(bufferlist& bufferlist, uint64_t offset,
49+
uint64_t length);
50+
51+
// Used for testing debug outputs from data generation
52+
virtual bufferlist generate_wrong_data(uint64_t offset, uint64_t length);
53+
54+
protected:
55+
const ObjectModel& m_model;
56+
57+
DataGenerator(const ObjectModel& model) : m_model(model) {}
58+
};
59+
60+
class SeededRandomGenerator : public DataGenerator {
61+
public:
62+
SeededRandomGenerator(const ObjectModel& model) : DataGenerator(model) {}
63+
64+
virtual bufferptr generate_block(uint64_t offset);
65+
virtual bufferlist generate_data(uint64_t length, uint64_t offset) override;
66+
virtual bufferptr generate_wrong_block(uint64_t offset);
67+
virtual bufferlist generate_wrong_data(uint64_t offset,
68+
uint64_t length) override;
69+
};
70+
71+
class HeaderedSeededRandomGenerator : public SeededRandomGenerator {
72+
public:
73+
HeaderedSeededRandomGenerator(
74+
const ObjectModel& model,
75+
std::optional<uint64_t> unique_run_id = std::nullopt);
76+
77+
bufferptr generate_block(uint64_t offset) override;
78+
bufferptr generate_wrong_block(uint64_t offset) override;
79+
bool validate(bufferlist& bufferlist, uint64_t offset,
80+
uint64_t length) override;
81+
82+
private:
83+
using UniqueIdBytes = uint64_t;
84+
using SeedBytes = int;
85+
using TimeBytes = uint64_t;
86+
87+
enum class ErrorType {
88+
RUN_ID_MISMATCH,
89+
SEED_MISMATCH,
90+
DATA_MISMATCH,
91+
DATA_NOT_FOUND,
92+
UNKNOWN
93+
};
94+
95+
constexpr uint8_t headerStart() const { return 0; };
96+
constexpr uint8_t uniqueIdStart() const { return headerStart(); };
97+
constexpr uint8_t uniqueIdLength() const { return sizeof(UniqueIdBytes); };
98+
constexpr uint8_t seedStart() const {
99+
return uniqueIdStart() + uniqueIdLength();
100+
};
101+
constexpr uint8_t seedLength() const { return sizeof(SeedBytes); };
102+
constexpr uint8_t timeStart() const { return seedStart() + seedLength(); };
103+
constexpr uint8_t timeLength() const { return sizeof(TimeBytes); };
104+
constexpr uint8_t timeEnd() const { return timeStart() + timeLength(); };
105+
constexpr uint8_t headerLength() const {
106+
return uniqueIdLength() + seedLength() + timeLength();
107+
};
108+
constexpr uint8_t bodyStart() const {
109+
return headerStart() + headerLength();
110+
};
111+
112+
const UniqueIdBytes readUniqueRunId(uint64_t block_offset,
113+
const bufferlist& bufferlist);
114+
const SeedBytes readSeed(uint64_t block_offset, const bufferlist& bufferlist);
115+
const TimeBytes readDateTime(uint64_t block_offset,
116+
const bufferlist& bufferlist);
117+
118+
const UniqueIdBytes unique_run_id;
119+
120+
uint64_t generate_unique_run_id();
121+
122+
bool validate_block(uint64_t block_offset, const char* buffer_start);
123+
124+
const ErrorType getErrorTypeForBlock(uint64_t read_offset,
125+
uint64_t block_offset,
123126
const bufferlist& bufferlist);
124127

125-
const UniqueIdBytes unique_run_id;
126-
127-
uint64_t generate_unique_run_id();
128-
129-
bool validate_block(uint64_t block_offset, const char* buffer_start);
130-
131-
const ErrorType getErrorTypeForBlock(uint64_t read_offset,
132-
uint64_t block_offset,
133-
const bufferlist& bufferlist);
134-
135-
void printDebugInformationForBlock(uint64_t read_offset,
136-
uint64_t block_offset,
137-
const bufferlist& bufferlist);
138-
void printDebugInformationForRange(uint64_t read_offset,
139-
uint64_t start_block_offset,
140-
uint64_t range_length_in_blocks,
141-
ErrorType rangeError,
142-
const bufferlist& bufferlist);
143-
144-
void printDebugInformationForRunIdMismatchRange(uint64_t read_offset,
145-
uint64_t start_block_offset,
146-
uint64_t range_length_in_blocks,
147-
const bufferlist& bufferlist);
148-
void printDebugInformationForSeedMismatchRange(uint64_t read_offset,
149-
uint64_t start_block_offset,
150-
uint64_t range_length_in_blocks,
151-
const bufferlist& bufferlist);
152-
void printDebugInformationDataBodyMismatchRange(uint64_t read_offset,
153-
uint64_t start_block_offset,
154-
uint64_t range_length_in_blocks,
155-
const bufferlist& bufferlist);
156-
void printDebugInformationDataNotFoundRange(uint64_t ßread_offset,
157-
uint64_t start_block_offset,
158-
uint64_t range_length_in_blocks,
159-
const bufferlist& bufferlist);
160-
void printDebugInformationCorruptRange(uint64_t read_offset,
161-
uint64_t start_block_offset,
162-
uint64_t range_length_in_blocks,
163-
const bufferlist& bufferlist);
164-
165-
void printDebugInformationForOffsets(uint64_t read_offset,
166-
std::vector<uint64_t> offsets,
167-
const bufferlist& bufferlist);
168-
};
169-
}
170-
}
171-
}
128+
void printDebugInformationForBlock(uint64_t read_offset,
129+
uint64_t block_offset,
130+
const bufferlist& bufferlist);
131+
void printDebugInformationForRange(uint64_t read_offset,
132+
uint64_t start_block_offset,
133+
uint64_t range_length_in_blocks,
134+
ErrorType rangeError,
135+
const bufferlist& bufferlist);
136+
137+
void printDebugInformationForRunIdMismatchRange(
138+
uint64_t read_offset, uint64_t start_block_offset,
139+
uint64_t range_length_in_blocks, const bufferlist& bufferlist);
140+
void printDebugInformationForSeedMismatchRange(
141+
uint64_t read_offset, uint64_t start_block_offset,
142+
uint64_t range_length_in_blocks, const bufferlist& bufferlist);
143+
void printDebugInformationDataBodyMismatchRange(
144+
uint64_t read_offset, uint64_t start_block_offset,
145+
uint64_t range_length_in_blocks, const bufferlist& bufferlist);
146+
void printDebugInformationDataNotFoundRange(uint64_t ßread_offset,
147+
uint64_t start_block_offset,
148+
uint64_t range_length_in_blocks,
149+
const bufferlist& bufferlist);
150+
void printDebugInformationCorruptRange(uint64_t read_offset,
151+
uint64_t start_block_offset,
152+
uint64_t range_length_in_blocks,
153+
const bufferlist& bufferlist);
154+
155+
void printDebugInformationForOffsets(uint64_t read_offset,
156+
std::vector<uint64_t> offsets,
157+
const bufferlist& bufferlist);
158+
};
159+
} // namespace data_generation
160+
} // namespace io_exerciser
161+
} // namespace ceph

0 commit comments

Comments
 (0)