ClickHouse

Форк
0
595 строк · 20.5 Кб
1
#include <cstring>
2
#include <filesystem>
3
#include <fstream>
4
#include <stdexcept>
5

6
#include <gtest/gtest.h>
7

8
#include <Common/tests/gtest_global_context.h>
9
#include <Common/tests/gtest_global_register.h>
10

11
#include <AggregateFunctions/IAggregateFunction.h>
12
#include <AggregateFunctions/registerAggregateFunctions.h>
13
#include <Processors/Merges/Algorithms/Graphite.h>
14
#include <Common/Config/ConfigProcessor.h>
15
#include <base/defines.h>
16
#include <base/errnoToString.h>
17

18

19
using namespace DB;
20

21
static ConfigProcessor::LoadedConfig loadConfiguration(const std::string & config_path)
22
{
23
    ConfigProcessor config_processor(config_path, true, true);
24
    ConfigProcessor::LoadedConfig config = config_processor.loadConfig(false);
25
    return config;
26
}
27

28
static ConfigProcessor::LoadedConfig loadConfigurationFromString(std::string & s)
29
{
30
    /// NOTE: This code is a trash, because it's written in C.
31
    /// We let it remain, because it's just some orphan old test.
32

33
    char tmp_file[19];
34
    strcpy(tmp_file, "/tmp/rollup-XXXXXX");
35
    int fd = mkstemp(tmp_file);
36
    if (fd == -1)
37
    {
38
        throw std::runtime_error(errnoToString());
39
    }
40
    try
41
    {
42
        if (write(fd, s.c_str(), s.size()) < s.size())
43
        {
44
            throw std::runtime_error("unable write to temp file");
45
        }
46
        if (write(fd, "\n", 1) != 1)
47
        {
48
            throw std::runtime_error("unable write to temp file");
49
        }
50
        int error = close(fd);
51
        chassert(!error);
52

53
        auto config_path = std::string(tmp_file) + ".xml";
54
        if (std::rename(tmp_file, config_path.c_str()))
55
        {
56
            int err = errno;
57
            (void)remove(tmp_file);
58
            throw std::runtime_error(errnoToString(err));
59
        }
60
        ConfigProcessor::LoadedConfig config = loadConfiguration(config_path);
61
        (void)remove(tmp_file);
62
        return config;
63
    }
64
    catch (...)
65
    {
66
        (void)remove(tmp_file);
67
        throw;
68
    }
69
}
70

71
static Graphite::Params setGraphitePatterns(ContextMutablePtr context, ConfigProcessor::LoadedConfig & config)
72
{
73
    context->setConfig(config.configuration);
74

75
    Graphite::Params params;
76
    setGraphitePatternsFromConfig(context, "graphite_rollup", params);
77

78
    return params;
79
}
80

81
struct  PatternForCheck
82
{
83
    Graphite::RuleType rule_type;
84
    std::string regexp_str;
85
    String function;
86
    Graphite::Retentions retentions;
87
};
88

89

90
bool checkRule(const Graphite::Pattern & pattern, const struct PatternForCheck & pattern_check,
91
    const std::string & typ, const std::string & path, std::string & message)
92
{
93
    bool rule_type_eq = (pattern.rule_type == pattern_check.rule_type);
94
    bool regexp_eq = (pattern.regexp_str == pattern_check.regexp_str);
95
    bool function_eq = (pattern.function == nullptr && pattern_check.function.empty())
96
                    || (pattern.function != nullptr && pattern.function->getName() == pattern_check.function);
97
    bool retentions_eq = (pattern.retentions == pattern_check.retentions);
98

99
    if (rule_type_eq && regexp_eq && function_eq && retentions_eq)
100
        return true;
101

102
    message = typ + " rollup rule mismatch for '" + path + "'," +
103
        (rule_type_eq ? "" : "rule_type ") +
104
        (regexp_eq ? "" : "regexp ") +
105
        (function_eq ? "" : "function ") +
106
        (retentions_eq ? "" : "retentions ");
107
    return false;
108
}
109

110
std::ostream & operator<<(std::ostream & stream, const PatternForCheck & a)
111
{
112
    stream << "{ rule_type = " << ruleTypeStr(a.rule_type);
113
    if (!a.regexp_str.empty())
114
        stream << ", regexp = '" << a.regexp_str << "'";
115
    if (!a.function.empty())
116
        stream << ", function = " << a.function;
117
    if (!a.retentions.empty())
118
    {
119
        stream << ",\n  retentions = {\n";
120
        for (size_t i = 0; i < a.retentions.size(); i++)
121
        {
122
            stream << "    { " << a.retentions[i].age << ", " << a.retentions[i].precision << " }";
123
            if (i < a.retentions.size() - 1)
124
                stream << ",";
125
            stream << "\n";
126
        }
127
        stream << "  }\n";
128
    }
129
    else
130
        stream << " ";
131

132
    stream << "}";
133
    return stream;
134
}
135

136
struct PatternsForPath
137
{
138
    std::string path;
139
    PatternForCheck retention_want;
140
    PatternForCheck aggregation_want;
141
};
142

143
TEST(GraphiteTest, testSelectPattern)
144
{
145
    tryRegisterAggregateFunctions();
146

147
    using namespace std::literals;
148

149
    std::string
150
        xml(R"END(<clickhouse>
151
<graphite_rollup>
152
    <pattern>
153
        <regexp>\.sum$</regexp>
154
        <function>sum</function>
155
    </pattern>
156
    <pattern>
157
        <regexp>^((.*)|.)sum\?</regexp>
158
        <function>sum</function>
159
    </pattern>
160
    <pattern>
161
        <regexp>\.max$</regexp>
162
        <function>max</function>
163
    </pattern>
164
    <pattern>
165
        <regexp>^((.*)|.)max\?</regexp>
166
        <function>max</function>
167
    </pattern>
168
    <pattern>
169
        <regexp>\.min$</regexp>
170
        <function>min</function>
171
    </pattern>
172
    <pattern>
173
        <regexp>^((.*)|.)min\?</regexp>
174
        <function>min</function>
175
    </pattern>
176
    <pattern>
177
        <regexp>\.(count|sum|sum_sq)$</regexp>
178
        <function>sum</function>
179
    </pattern>
180
    <pattern>
181
        <regexp>^((.*)|.)(count|sum|sum_sq)\?</regexp>
182
        <function>sum</function>
183
    </pattern>
184
    <pattern>
185
        <regexp>^retention\.</regexp>
186
        <retention>
187
            <age>0</age>
188
            <precision>60</precision>
189
        </retention>
190
        <retention>
191
            <age>86400</age>
192
            <precision>3600</precision>
193
        </retention>
194
    </pattern>
195
    <default>
196
        <function>avg</function>
197
        <retention>
198
            <age>0</age>
199
            <precision>60</precision>
200
        </retention>
201
        <retention>
202
            <age>3600</age>
203
            <precision>300</precision>
204
        </retention>
205
        <retention>
206
            <age>86400</age>
207
            <precision>3600</precision>
208
        </retention>
209
    </default>
210
</graphite_rollup>
211
</clickhouse>
212
)END");
213

214
    // Retentions must be ordered by 'age' descending.
215
    std::vector<struct PatternsForPath> tests
216
    {
217
        {
218
            "test.sum",
219
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
220
            { Graphite::RuleTypeAll, R"END(\.sum$)END", "sum", { } }
221
        },
222
        {
223
            "val.sum?env=test&tag=Fake3",
224
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
225
            { Graphite::RuleTypeAll, R"END(^((.*)|.)sum\?)END", "sum", { } }
226
        },
227
        {
228
            "test.max",
229
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
230
            { Graphite::RuleTypeAll, R"END(\.max$)END", "max", { } },
231
        },
232
        {
233
            "val.max?env=test&tag=Fake4",
234
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
235
            { Graphite::RuleTypeAll, R"END(^((.*)|.)max\?)END", "max", { } },
236
        },
237
        {
238
            "test.min",
239
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
240
            { Graphite::RuleTypeAll, R"END(\.min$)END", "min", { } },
241
        },
242
        {
243
            "val.min?env=test&tag=Fake5",
244
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
245
            { Graphite::RuleTypeAll, R"END(^((.*)|.)min\?)END", "min", { } },
246
        },
247
        {
248
            "retention.count",
249
            { Graphite::RuleTypeAll, R"END(^retention\.)END", "", { { 86400, 3600 }, { 0, 60 } } }, // ^retention
250
            { Graphite::RuleTypeAll, R"END(\.(count|sum|sum_sq)$)END", "sum", { } },
251
        },
252
        {
253
            "val.retention.count?env=test&tag=Fake5",
254
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
255
            { Graphite::RuleTypeAll, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
256
        },
257
        {
258
            "val.count?env=test&tag=Fake5",
259
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
260
            { Graphite::RuleTypeAll, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
261
        },
262
        {
263
            "test.p95",
264
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
265
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
266
        },
267
        {
268
            "val.p95?env=test&tag=FakeNo",
269
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
270
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
271
        },
272
        {
273
            "default",
274
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
275
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
276
        },
277
        {
278
            "val.default?env=test&tag=FakeNo",
279
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
280
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
281
        }
282
    };
283

284
    auto config = loadConfigurationFromString(xml);
285
    ContextMutablePtr context = getContext().context;
286
    Graphite::Params params = setGraphitePatterns(context, config);
287

288
    for (const auto & t : tests)
289
    {
290
        auto rule = DB::Graphite::selectPatternForPath(params, t.path);
291
        std:: string message;
292
        if (!checkRule(*rule.first, t.retention_want, "retention", t.path, message))
293
            ADD_FAILURE() << message << ", got\n" << *rule.first << "\n, want\n" << t.retention_want << "\n";
294
        if (!checkRule(*rule.second, t.aggregation_want, "aggregation", t.path, message))
295
            ADD_FAILURE() << message << ", got\n" << *rule.second << "\n, want\n" << t.aggregation_want << "\n";
296
    }
297
}
298

299

300
namespace DB::Graphite
301
{
302
    std::string buildTaggedRegex(std::string regexp_str);
303
}
304

305
struct RegexCheck
306
{
307
    std::string regex;
308
    std::string regex_want;
309
    std::string match;
310
    std::string nomatch;
311
};
312

313
TEST(GraphiteTest, testBuildTaggedRegex)
314
{
315
    std::vector<struct RegexCheck> tests
316
    {
317
        {
318
            "cpu\\.loadavg;project=DB.*;env=st.*",
319
            R"END(^cpu\.loadavg\?(.*&)?env=st.*&(.*&)?project=DB.*(&.*)?$)END",
320
            R"END(cpu.loadavg?env=staging&project=DBAAS)END",
321
            R"END(cpu.loadavg?env=staging&project=D)END"
322
        },
323
        {
324
            R"END(project=DB.*;env=staging;)END",
325
            R"END([\?&]env=staging&(.*&)?project=DB.*(&.*)?$)END",
326
            R"END(cpu.loadavg?env=staging&project=DBPG)END",
327
            R"END(cpu.loadavg?env=stagingN&project=DBAAS)END"
328
        },
329
        {
330
            "env=staging;",
331
            R"END([\?&]env=staging(&.*)?$)END",
332
            R"END(cpu.loadavg?env=staging&project=DPG)END",
333
            R"END(cpu.loadavg?env=stagingN)END"
334
        },
335
        {
336
            " env = staging ;", // spaces are allowed,
337
            R"END([\?&] env = staging (&.*)?$)END",
338
            R"END(cpu.loadavg? env = staging &project=DPG)END",
339
            R"END(cpu.loadavg?env=stagingN)END"
340
        },
341
        {
342
            "name;",
343
            R"END(^name\?)END",
344
            R"END(name?env=staging&project=DPG)END",
345
            R"END(nameN?env=stagingN)END",
346
        },
347
        {
348
            "name",
349
            R"END(^name\?)END",
350
            R"END(name?env=staging&project=DPG)END",
351
            R"END(nameN?env=stagingN)END",
352
        }
353
    };
354
    for (const auto & t : tests)
355
    {
356
        auto s = DB::Graphite::buildTaggedRegex(t.regex);
357
        EXPECT_EQ(t.regex_want, s) << "result for '" << t.regex_want << "' mismatch";
358
        auto regexp = OptimizedRegularExpression(s);
359
        EXPECT_TRUE(regexp.match(t.match.data(), t.match.size())) << t.match << " match for '" << s << "' failed";
360
        EXPECT_FALSE(regexp.match(t.nomatch.data(), t.nomatch.size())) << t.nomatch << " ! match for '" << s << "' failed";
361
    }
362
}
363

364
TEST(GraphiteTest, testSelectPatternTyped)
365
{
366
    tryRegisterAggregateFunctions();
367

368
    using namespace std::literals;
369

370
    std::string
371
        xml(R"END(<clickhouse>
372
<graphite_rollup>
373
    <pattern>
374
        <rule_type>plain</rule_type>
375
        <regexp>\.sum$</regexp>
376
        <function>sum</function>
377
    </pattern>
378
    <pattern>
379
        <rule_type>tagged</rule_type>
380
        <regexp>^((.*)|.)sum\?</regexp>
381
        <function>sum</function>
382
    </pattern>
383
    <pattern>
384
        <rule_type>plain</rule_type>
385
        <regexp>\.max$</regexp>
386
        <function>max</function>
387
    </pattern>
388
    <pattern>
389
        <rule_type>tagged</rule_type>
390
        <regexp>^((.*)|.)max\?</regexp>
391
        <function>max</function>
392
    </pattern>
393
    <pattern>
394
        <rule_type>plain</rule_type>
395
        <regexp>\.min$</regexp>
396
        <function>min</function>
397
    </pattern>
398
    <pattern>
399
        <rule_type>tagged</rule_type>
400
        <regexp>^((.*)|.)min\?</regexp>
401
        <function>min</function>
402
    </pattern>
403
    <pattern>
404
    <rule_type>plain</rule_type>
405
     <regexp>\.(count|sum|sum_sq)$</regexp>
406
     <function>sum</function>
407
    </pattern>
408
    <pattern>
409
        <rule_type>tagged</rule_type>
410
        <regexp>^((.*)|.)(count|sum|sum_sq)\?</regexp>
411
        <function>sum</function>
412
    </pattern>
413
    <pattern>
414
        <rule_type>plain</rule_type>
415
        <regexp>^retention\.</regexp>
416
        <retention>
417
            <age>0</age>
418
            <precision>60</precision>
419
        </retention>
420
        <retention>
421
            <age>86400</age>
422
            <precision>3600</precision>
423
        </retention>
424
    </pattern>
425
    <pattern>
426
        <rule_type>tagged</rule_type>
427
        <regexp><![CDATA[[\?&]retention=hour(&.*)?$]]></regexp>
428
        <retention>
429
            <age>0</age>
430
            <precision>60</precision>
431
        </retention>
432
        <retention>
433
            <age>86400</age>
434
            <precision>3600</precision>
435
        </retention>
436
    </pattern>
437
    <pattern>
438
        <rule_type>tag_list</rule_type>
439
        <regexp>retention=10min;env=staging</regexp>
440
        <retention>
441
            <age>0</age>
442
            <precision>600</precision>
443
        </retention>
444
        <retention>
445
            <age>86400</age>
446
            <precision>3600</precision>
447
        </retention>
448
    </pattern>
449
    <pattern>
450
        <rule_type>tag_list</rule_type>
451
        <regexp>retention=10min;env=[A-Za-z-]+rod[A-Za-z-]+</regexp>
452
        <retention>
453
            <age>0</age>
454
            <precision>600</precision>
455
        </retention>
456
        <retention>
457
            <age>86400</age>
458
            <precision>3600</precision>
459
        </retention>
460
    </pattern>
461
    <pattern>
462
        <rule_type>tag_list</rule_type>
463
        <regexp>cpu\.loadavg</regexp>
464
        <retention>
465
            <age>0</age>
466
            <precision>600</precision>
467
        </retention>
468
        <retention>
469
            <age>86400</age>
470
            <precision>3600</precision>
471
        </retention>
472
    </pattern>
473
    <default>
474
        <function>avg</function>
475
        <retention>
476
            <age>0</age>
477
            <precision>60</precision>
478
        </retention>
479
        <retention>
480
            <age>3600</age>
481
            <precision>300</precision>
482
        </retention>
483
        <retention>
484
            <age>86400</age>
485
            <precision>3600</precision>
486
        </retention>
487
    </default>
488
</graphite_rollup>
489
</clickhouse>
490
)END");
491

492
    // Retentions must be ordered by 'age' descending.
493
    std::vector<PatternsForPath> tests
494
    {
495
        {
496
            "test.sum",
497
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
498
            { Graphite::RuleTypePlain, R"END(\.sum$)END", "sum", { } }
499
        },
500
        {
501
            "val.sum?env=test&tag=Fake3",
502
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
503
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)sum\?)END", "sum", { } }
504
        },
505
        {
506
            "test.max",
507
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
508
            { Graphite::RuleTypePlain, R"END(\.max$)END", "max", { } },
509
        },
510
        {
511
            "val.max?env=test&tag=Fake4",
512
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
513
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)max\?)END", "max", { } },
514
        },
515
        {
516
            "test.min",
517
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
518
            { Graphite::RuleTypePlain, R"END(\.min$)END", "min", { } },
519
        },
520
        {
521
            "val.min?env=test&tag=Fake5",
522
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
523
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)min\?)END", "min", { } },
524
        },
525
        {
526
            "retention.count",
527
            { Graphite::RuleTypePlain, R"END(^retention\.)END", "", { { 86400, 3600 }, { 0, 60 } } }, // ^retention
528
            { Graphite::RuleTypePlain, R"END(\.(count|sum|sum_sq)$)END", "sum", { } },
529
        },
530
        {
531
            "val.count?env=test&retention=hour&tag=Fake5",
532
            { Graphite::RuleTypeTagged, R"END([\?&]retention=hour(&.*)?$)END", "", { { 86400, 3600 }, { 0, 60 } } }, // tagged retention=hour
533
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
534
        },
535
        {
536
            "val.count?env=test&retention=hour",
537
            { Graphite::RuleTypeTagged, R"END([\?&]retention=hour(&.*)?$)END", "", { { 86400, 3600 }, { 0, 60 } } }, // tagged retention=hour
538
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
539
        },
540
        {
541
            "val.count?env=staging&retention=10min",
542
            { Graphite::RuleTypeTagged, R"END([\?&]env=staging&(.*&)?retention=10min(&.*)?$)END", "", { { 86400, 3600 }, { 0, 600 } } }, // retention=10min ; env=staging
543
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
544
        },
545
        {
546
            "val.count?env=production&retention=10min",
547
            { Graphite::RuleTypeTagged, R"END([\?&]env=[A-Za-z-]+rod[A-Za-z-]+&(.*&)?retention=10min(&.*)?$)END", "", { { 86400, 3600 }, { 0, 600 } } }, // retention=10min ; env=[A-Za-z-]+rod[A-Za-z-]+
548
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
549
        },
550
        {
551
            "val.count?env=test&tag=Fake5",
552
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
553
            { Graphite::RuleTypeTagged, R"END(^((.*)|.)(count|sum|sum_sq)\?)END", "sum", { } },
554
        },
555
        {
556
            "cpu.loadavg?env=test&tag=FakeNo",
557
            { Graphite::RuleTypeTagged, R"END(^cpu\.loadavg\?)END", "", { { 86400, 3600 }, { 0, 600 } } }, // name=cpu\.loadavg
558
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } },
559
        },
560
        {
561
            "test.p95",
562
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
563
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
564
        },
565
        {
566
            "val.p95?env=test&tag=FakeNo",
567
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
568
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
569
        },
570
        {
571
            "default",
572
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
573
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
574
        },
575
        {
576
            "val.default?env=test&tag=FakeNo",
577
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
578
            { Graphite::RuleTypeAll, "", "avg", { { 86400, 3600 }, { 3600, 300 }, { 0, 60 } } }, //default
579
        }
580
    };
581

582
    auto config = loadConfigurationFromString(xml);
583
    ContextMutablePtr context = getContext().context;
584
    Graphite::Params params = setGraphitePatterns(context, config);
585

586
    for (const auto & t : tests)
587
    {
588
        auto rule = DB::Graphite::selectPatternForPath(params, t.path);
589
        std:: string message;
590
        if (!checkRule(*rule.first, t.retention_want, "retention", t.path, message))
591
            ADD_FAILURE() << message << ", got\n" << *rule.first << "\n, want\n" << t.retention_want << "\n";
592
        if (!checkRule(*rule.second, t.aggregation_want, "aggregation", t.path, message))
593
            ADD_FAILURE() << message << ", got\n" << *rule.second << "\n, want\n" << t.aggregation_want << "\n";
594
    }
595
}
596

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.