forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_WorkflowSerialization.cxx
More file actions
122 lines (104 loc) · 9.06 KB
/
test_WorkflowSerialization.cxx
File metadata and controls
122 lines (104 loc) · 9.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/WorkflowSpec.h"
#include "../src/WorkflowSerializationHelpers.h"
#include <catch_amalgamated.hpp>
using namespace o2::framework;
TEST_CASE("TestVerifyWorkflowSerialization")
{
using namespace o2::framework;
WorkflowSpec w0{ //
DataProcessorSpec{"A", //
{InputSpec{"foo", "A", "COLLISIONCONTEXT", 1, Lifetime::Condition, {
ConfigParamSpec{"aUrl", VariantType::String, "foo/bar", {"A InputSpec option"}}, //
ConfigParamSpec{"bUrl", VariantType::String, "foo/foo", {"Another InputSpec option"}}, //
}}}, //
{OutputSpec{{"bar"}, "C", "D", 2, Lifetime::Timeframe}}, //
AlgorithmSpec{[](ProcessingContext& ctx) {}}, //
{ //
ConfigParamSpec{"aInt", VariantType::Int, 0, {"An Int"}}, //
ConfigParamSpec{"aFloat", VariantType::Float, 1.3, {"A Float"}}, //
ConfigParamSpec{"aBool", VariantType::Bool, true, {"A Bool"}}, //
ConfigParamSpec{"aString", VariantType::String, "some string", {"A String"}}}}, // //
DataProcessorSpec{"B", //
{InputSpec{"foo", "C", "D"}}, //
{ //
OutputSpec{{"bar1"}, "E", "F", 0}, //
OutputSpec{{"bar2"}, "E", "F", 1}}, //
AlgorithmSpec{[](ProcessingContext& ctx) {}}, //
{}}, //
DataProcessorSpec{"C", {}, //
{ //
OutputSpec{{"bar"}, "G", "H"}}, //
AlgorithmSpec{[](ProcessingContext& ctx) {}}, //
{}}, //
DataProcessorSpec{"D", {InputSpec{"foo", {"C", "D"}}}, //
{OutputSpec{{"bar"}, {"I", "L"}}}, //
AlgorithmSpec{[](ProcessingContext& ctx) {}}, //
{}, //
CommonServices::defaultServices(), //
{{"label a"}, {"label \"b\""}},
{{"key1", "v\"al'1"}, {"", "val2"}, {"key3", ""}, {"", ""}}}};
std::vector<DataProcessorInfo> dataProcessorInfoOut{
{.name = "A", .executable = "test_Framework_test_SerializationWorkflow", .cmdLineArgs = {"foo"}, .workflowOptions = {ConfigParamSpec{"aBool", VariantType::Bool, true, {"A Bool"}}}},
{.name = "B", .executable = "test_Framework_test_SerializationWorkflow", .cmdLineArgs = {"b-bar", "bfoof", "fbdbfaso"}},
{.name = "C", .executable = "test_Framework_test_SerializationWorkflow"},
{.name = "D", .executable = "test_Framework_test_SerializationWorkflow"},
};
CommandInfo commandInfoOut{"o2-dpl-workflow -b --option 1 --option 2"};
std::vector<DataProcessorInfo> dataProcessorInfoIn{};
CommandInfo commandInfoIn;
std::ostringstream firstDump;
WorkflowSerializationHelpers::dump(firstDump, w0, dataProcessorInfoOut, commandInfoOut);
std::istringstream is;
is.str(firstDump.str());
WorkflowSpec w1;
WorkflowSerializationHelpers::import(is, w1, dataProcessorInfoIn, commandInfoIn);
std::ostringstream secondDump;
WorkflowSerializationHelpers::dump(secondDump, w1, dataProcessorInfoIn, commandInfoIn);
REQUIRE(w0.size() == 4);
REQUIRE(w0.size() == w1.size());
REQUIRE(firstDump.str() == secondDump.str());
REQUIRE(commandInfoIn.command == commandInfoOut.command);
// also check if the conversion to ConcreteDataMatcher is working at import
REQUIRE(std::get_if<ConcreteDataMatcher>(&w1[0].inputs[0].matcher) != nullptr);
}
/// Test a workflow with a single data processor with a single input
/// which has a wildcard on subspec.
TEST_CASE("TestVerifyWildcard")
{
using namespace o2::framework;
WorkflowSpec w0{
DataProcessorSpec{
.name = "A",
.inputs = {{"clbPayload", "CLP"}, {"clbWrapper", "CLW"}},
}};
std::vector<DataProcessorInfo> dataProcessorInfoOut{
{.name = "A", .executable = "test_Framework_test_SerializationWorkflow"},
};
CommandInfo commandInfoOut{"o2-dpl-workflow -b --option 1 --option 2"};
std::vector<DataProcessorInfo> dataProcessorInfoIn{};
CommandInfo commandInfoIn;
std::ostringstream firstDump;
WorkflowSerializationHelpers::dump(firstDump, w0, dataProcessorInfoOut, commandInfoOut);
std::istringstream is;
is.str(firstDump.str());
WorkflowSpec w1;
WorkflowSerializationHelpers::import(is, w1, dataProcessorInfoIn, commandInfoIn);
std::ostringstream secondDump;
WorkflowSerializationHelpers::dump(secondDump, w1, dataProcessorInfoIn, commandInfoIn);
REQUIRE(w0.size() == 1);
REQUIRE(w0.size() == w1.size());
REQUIRE(firstDump.str() == secondDump.str());
REQUIRE(commandInfoIn.command == commandInfoOut.command);
// also check if the conversion to ConcreteDataMatcher is working at import
// REQUIRE(std::get_if<ConcreteDataTypeMatcher>(&w1[0].inputs[0].matcher) != nullptr);;
}