13#include <catch_amalgamated.hpp>
14#include "../src/O2ControlHelpers.h"
15#include "../src/DeviceSpecHelpers.h"
16#include "../src/SimpleResourceManager.h"
17#include "../src/ComputingResourceHelpers.h"
36 "name=into_dpl,type=pull,method=connect,address=ipc:///tmp/pipe-into-dpl,transport=shmem,rateLogging=10,rcvBufSize=789",
37 {
"Out-of-band channel config"}}}},
43 .labels = {{
"expendable"}},
47 .options = {
ConfigParamSpec{
"a-param", VariantType::Int, 1, {
"A parameter which should not be escaped"}},
48 ConfigParamSpec{
"b-param", VariantType::String,
"", {
"a parameter which will be escaped"}},
49 ConfigParamSpec{
"c-param", VariantType::String,
"foo;bar", {
"another parameter which will be escaped"}},
50 ConfigParamSpec{
"d-param", VariantType::String, R
"(["foo","bar"])", {"a parameter with double quotes"}},
52 "name=outta_dpl,type=push,method=bind,address=ipc:///tmp/pipe-outta-dpl,transport=shmem,rateLogging=10",
53 {
"Out-of-band channel config"}}},
54 .labels = {{
"resilient"}}}};
57char* strdiffchr(
const char*
s1,
const char* s2)
59 while (*
s1 && *
s1 == *s2) {
63 return (*
s1 == *s2) ? nullptr : (
char*)
s1;
70 o2-exe --abdf -defg 'asdf fdsa' | o2-exe-2 -b --zxcv "asdf zxcv"
72 monitoring_dpl_url: "no-op://"
75 shm_segment_size: 10000000000
76 shm_throw_bad_alloc: false
78 resources_monitoring: 15
85 target: "::into_dpl-{{ it }}"
86 rateLogging: "{{ fmq_rate_logging }}"
101 target: "{{ Parent().Path }}.A:from_A_to_C"
102 rateLogging: "{{ fmq_rate_logging }}"
108 target: "{{ Parent().Path }}.B:from_B_to_C"
109 rateLogging: "{{ fmq_rate_logging }}"
120 target: "{{ Parent().Path }}.C:from_C_to_D"
121 rateLogging: "{{ fmq_rate_logging }}"
129 rateLogging: "{{ fmq_rate_logging }}"
130 global: "outta_dpl-{{ it }}"
139 log_task_stdout: none
140 log_task_stderr: none
141 exit_transition_timeout: 15
142 data_processing_timeout: 10
144 source /etc/profile.d/modules.sh && MODULEPATH={{ modulepath }} module load O2 QualityControl Control-OCCPlugin &&
145 {{ dpl_command }} | bcsadc/foo
147 source /etc/profile.d/o2.sh && {{ len(extra_env_vars)>0 ? 'export ' + extra_env_vars + ' &&' : '' }} {{ dpl_command }} | bcsadc/foo
158 rateLogging: "{{ fmq_rate_logging }}"
163 stdout: "{{ log_task_stdout }}"
164 stderr: "{{ log_task_stderr }}"
166 - O2_DETECTOR={{ detector }}
167 - O2_PARTITION={{ environment_id }}
170 value: "{{ len(modulepath)>0 ? _module_cmdline : _plain_cmdline }}"
173 - "--exit-transition-timeout"
174 - "'{{ exit_transition_timeout }}'"
175 - "--data-processing-timeout"
176 - "'{{ data_processing_timeout }}'"
177 - "--monitoring-backend"
178 - "'{{ monitoring_dpl_url }}'"
180 - "'{{ session_id }}'"
181 - "--infologger-severity"
182 - "'{{ infologger_severity }}'"
183 - "--infologger-mode"
184 - "'{{ infologger_mode }}'"
185 - "--driver-client-backend"
187 - "--shm-segment-size"
188 - "'{{ shm_segment_size }}'"
189 - "--shm-throw-bad-alloc"
190 - "'{{ shm_throw_bad_alloc }}'"
191 - "--resources-monitoring"
192 - "'{{ resources_monitoring }}'"
200 - "--bad-alloc-attempt-interval"
202 - "--bad-alloc-max-attempts"
206 - "--early-forward-policy"
215 - "'rbtree_best_fit'"
216 - "--shm-metadata-msg-size"
218 - "--shm-mlock-segment"
220 - "--shm-mlock-segment-on-creation"
226 - "--shm-zero-segment"
230 - "--stacktrace-on-signal"
232 - "--timeframes-rate-limit"
237 log_task_stdout: none
238 log_task_stderr: none
239 exit_transition_timeout: 15
240 data_processing_timeout: 10
242 source /etc/profile.d/modules.sh && MODULEPATH={{ modulepath }} module load O2 QualityControl Control-OCCPlugin &&
243 {{ dpl_command }} | foo
245 source /etc/profile.d/o2.sh && {{ len(extra_env_vars)>0 ? 'export ' + extra_env_vars + ' &&' : '' }} {{ dpl_command }} | foo
258 rateLogging: "{{ fmq_rate_logging }}"
263 stdout: "{{ log_task_stdout }}"
264 stderr: "{{ log_task_stderr }}"
266 - O2_DETECTOR={{ detector }}
267 - O2_PARTITION={{ environment_id }}
270 value: "{{ len(modulepath)>0 ? _module_cmdline : _plain_cmdline }}"
273 - "--exit-transition-timeout"
274 - "'{{ exit_transition_timeout }}'"
275 - "--data-processing-timeout"
276 - "'{{ data_processing_timeout }}'"
277 - "--monitoring-backend"
278 - "'{{ monitoring_dpl_url }}'"
280 - "'{{ session_id }}'"
281 - "--infologger-severity"
282 - "'{{ infologger_severity }}'"
283 - "--infologger-mode"
284 - "'{{ infologger_mode }}'"
285 - "--driver-client-backend"
287 - "--shm-segment-size"
288 - "'{{ shm_segment_size }}'"
289 - "--shm-throw-bad-alloc"
290 - "'{{ shm_throw_bad_alloc }}'"
291 - "--resources-monitoring"
292 - "'{{ resources_monitoring }}'"
300 - "--bad-alloc-attempt-interval"
302 - "--bad-alloc-max-attempts"
306 - "--early-forward-policy"
315 - "'rbtree_best_fit'"
316 - "--shm-metadata-msg-size"
318 - "--shm-mlock-segment"
320 - "--shm-mlock-segment-on-creation"
326 - "--shm-zero-segment"
330 - "--stacktrace-on-signal"
332 - "--timeframes-rate-limit"
337 log_task_stdout: none
338 log_task_stderr: none
339 exit_transition_timeout: 15
340 data_processing_timeout: 10
342 source /etc/profile.d/modules.sh && MODULEPATH={{ modulepath }} module load O2 QualityControl Control-OCCPlugin &&
343 {{ dpl_command }} | foo
345 source /etc/profile.d/o2.sh && {{ len(extra_env_vars)>0 ? 'export ' + extra_env_vars + ' &&' : '' }} {{ dpl_command }} | foo
358 rateLogging: "{{ fmq_rate_logging }}"
363 stdout: "{{ log_task_stdout }}"
364 stderr: "{{ log_task_stderr }}"
366 - O2_DETECTOR={{ detector }}
367 - O2_PARTITION={{ environment_id }}
370 value: "{{ len(modulepath)>0 ? _module_cmdline : _plain_cmdline }}"
373 - "--exit-transition-timeout"
374 - "'{{ exit_transition_timeout }}'"
375 - "--data-processing-timeout"
376 - "'{{ data_processing_timeout }}'"
377 - "--monitoring-backend"
378 - "'{{ monitoring_dpl_url }}'"
380 - "'{{ session_id }}'"
381 - "--infologger-severity"
382 - "'{{ infologger_severity }}'"
383 - "--infologger-mode"
384 - "'{{ infologger_mode }}'"
385 - "--driver-client-backend"
387 - "--shm-segment-size"
388 - "'{{ shm_segment_size }}'"
389 - "--shm-throw-bad-alloc"
390 - "'{{ shm_throw_bad_alloc }}'"
391 - "--resources-monitoring"
392 - "'{{ resources_monitoring }}'"
400 - "--bad-alloc-attempt-interval"
402 - "--bad-alloc-max-attempts"
406 - "--early-forward-policy"
415 - "'rbtree_best_fit'"
416 - "--shm-metadata-msg-size"
418 - "--shm-mlock-segment"
420 - "--shm-mlock-segment-on-creation"
426 - "--shm-zero-segment"
430 - "--stacktrace-on-signal"
432 - "--timeframes-rate-limit"
437 log_task_stdout: none
438 log_task_stderr: none
439 exit_transition_timeout: 15
440 data_processing_timeout: 10
442 source /etc/profile.d/modules.sh && MODULEPATH={{ modulepath }} module load O2 QualityControl Control-OCCPlugin &&
443 {{ dpl_command }} | foo
445 source /etc/profile.d/o2.sh && {{ len(extra_env_vars)>0 ? 'export ' + extra_env_vars + ' &&' : '' }} {{ dpl_command }} | foo
456 rateLogging: "{{ fmq_rate_logging }}"
457 global: "outta_dpl-{{ it }}"
460 stdout: "{{ log_task_stdout }}"
461 stderr: "{{ log_task_stderr }}"
463 - O2_DETECTOR={{ detector }}
464 - O2_PARTITION={{ environment_id }}
467 value: "{{ len(modulepath)>0 ? _module_cmdline : _plain_cmdline }}"
470 - "--exit-transition-timeout"
471 - "'{{ exit_transition_timeout }}'"
472 - "--data-processing-timeout"
473 - "'{{ data_processing_timeout }}'"
474 - "--monitoring-backend"
475 - "'{{ monitoring_dpl_url }}'"
477 - "'{{ session_id }}'"
478 - "--infologger-severity"
479 - "'{{ infologger_severity }}'"
480 - "--infologger-mode"
481 - "'{{ infologger_mode }}'"
482 - "--driver-client-backend"
484 - "--shm-segment-size"
485 - "'{{ shm_segment_size }}'"
486 - "--shm-throw-bad-alloc"
487 - "'{{ shm_throw_bad_alloc }}'"
488 - "--resources-monitoring"
489 - "'{{ resources_monitoring }}'"
497 - "--bad-alloc-attempt-interval"
499 - "--bad-alloc-max-attempts"
503 - "--early-forward-policy"
512 - "'rbtree_best_fit'"
513 - "--shm-metadata-msg-size"
515 - "--shm-mlock-segment"
517 - "--shm-mlock-segment-on-creation"
523 - "--shm-zero-segment"
527 - "--stacktrace-on-signal"
529 - "--timeframes-rate-limit"
538 - "'[\"foo\",\"bar\"]'"
544 std::ostringstream ss{
""};
546 auto channelPolicies = makeTrivialChannelPolicies(*configContext);
547 std::vector<DeviceSpec> devices;
553 std::vector<DeviceControl> controls;
554 std::vector<DeviceExecution> executions;
555 controls.resize(devices.size());
556 executions.resize(devices.size());
557 CommandInfo commandInfo{R
"(o2-exe --abdf -defg 'asdf fdsa' | o2-exe-2 -b --zxcv "asdf zxcv")"};
559 std::vector<ConfigParamSpec> workflowOptions = {
560 ConfigParamSpec{"jobs", VariantType::Int, 1, {
"number of producer jobs"}}};
562 std::vector<DataProcessorInfo> dataProcessorInfos = {
564 {.
name =
"A", .executable =
"bcsadc/foo", .workflowOptions = workflowOptions},
565 {.name =
"B", .executable =
"foo", .workflowOptions = workflowOptions},
566 {.name =
"C", .executable =
"foo", .workflowOptions = workflowOptions},
567 {.name =
"D", .executable =
"foo", .workflowOptions = workflowOptions},
576 devices, executions, controls, {},
579 dumpWorkflow(ss, devices, executions, commandInfo,
"testwf",
"");
584 REQUIRE(devices.size() == executions.size());
586 for (
size_t di = 0;
di < devices.size(); ++
di) {
587 auto& spec = devices[
di];
590 SECTION(
"Device " + std::string(spec.name))
595 REQUIRE(strdiffchr(ss.str().data(),
expected) == strdiffchr(
expected, ss.str().data()));
WorkflowSpec defineDataProcessing(ConfigContext const &configcontext)
std::unique_ptr< ConfigContext > makeEmptyConfigContext()
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
GLuint const GLchar * name
const decltype(DataProcessorMetadata::key) privateMemoryKillThresholdMB
const decltype(DataProcessorMetadata::key) cpuKillThreshold
Defining PrimaryVertex explicitly as messageable.
void dumpTask(std::ostream &dumpOut, const DeviceSpec &spec, const DeviceExecution &execution, std::string taskName, std::string indLevel)
Dumps only one task.
TEST_CASE("test_prepareArguments")
std::vector< DataProcessorSpec > WorkflowSpec
void dumpWorkflow(std::ostream &dumpOut, const std::vector< DeviceSpec > &specs, const std::vector< DeviceExecution > &executions, const CommandInfo &commandInfo, std::string workflowName, std::string indLevel)
Dumps only the workflow file.
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
static std::vector< CallbacksPolicy > createDefaultPolicies()
static std::vector< CompletionPolicy > createDefaultPolicies()
Helper to create the default configuration.
static ComputingResource getLocalhostResource()
static void prepareArguments(bool defaultQuiet, bool defaultStopped, bool intereactive, unsigned short driverPort, DriverConfig const &driverConfig, std::vector< DataProcessorInfo > const &processorInfos, std::vector< DeviceSpec > const &deviceSpecs, std::vector< DeviceExecution > &deviceExecutions, std::vector< DeviceControl > &deviceControls, std::vector< ConfigParamSpec > const &detectedOptions, std::string const &uniqueWorkflowId)
static void dataProcessorSpecs2DeviceSpecs(const WorkflowSpec &workflow, std::vector< ChannelConfigurationPolicy > const &channelPolicies, std::vector< CompletionPolicy > const &completionPolicies, std::vector< DispatchPolicy > const &dispatchPolicies, std::vector< ResourcePolicy > const &resourcePolicies, std::vector< CallbacksPolicy > const &callbacksPolicies, std::vector< SendingPolicy > const &sendingPolicy, std::vector< ForwardingPolicy > const &forwardingPolicies, std::vector< DeviceSpec > &devices, ResourceManager &resourceManager, std::string const &uniqueWorkflowId, ConfigContext const &configContext, bool optimizeTopology=false, unsigned short resourcesMonitoringInterval=0, std::string const &channelPrefix="", OverrideServiceSpecs const &overrideServices={})
bool batch
Whether the driver was started in batch mode or not.
std::vector< ConfigParamSpec > metadata
A set of configurables which can be used to customise the InputSpec.
std::map< std::string, ID > expected
const auto expectedWorkflow
const std::vector expectedTasks