Skip to content

Commit a20f4b9

Browse files
Mario-DLmergify[bot]
authored andcommitted
Add flow_control, rtps, custom_payload_pool and content_filter to windows example ci testing (#5480)
* Refs #21660: Flow controller example Signed-off-by: Mario-DL <[email protected]> * Refs #21660: RTPS example Signed-off-by: Mario-DL <[email protected]> * Refs #21660: Custom PayloadPool example Signed-off-by: Mario-DL <[email protected]> * Refs #21660: Additional cmake vars for configuring extra arguments lists Signed-off-by: Mario-DL <[email protected]> * Refs #21660: Content Filter example Signed-off-by: Mario-DL <[email protected]> * Refs #21660: Add examples to CMakeLists.txt Signed-off-by: Mario-DL <[email protected]> --------- Signed-off-by: Mario-DL <[email protected]> (cherry picked from commit 0deeb14) # Conflicts: # test/examples/CMakeLists.txt # test/examples/content_filter.compose.yml # test/examples/custom_payload_pool.compose.yml # test/examples/rtps.compose.yml
1 parent b0e1c69 commit a20f4b9

14 files changed

+176
-23
lines changed

examples/cpp/content_filter/CLIParser.hpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class CLIParser
6464
//! Subscriber application configuration structure
6565
struct subscriber_config
6666
{
67+
uint16_t samples = 0;
6768
CLIParser::FilterKind filter_kind = CLIParser::FilterKind::DEFAULT;
6869
std::string filter_expression = "index between %0 and %1";
6970
std::string upper_bound = "9";
@@ -102,8 +103,8 @@ class CLIParser
102103
std::cout << " (Default: Best effort)" << std::endl;
103104
std::cout << " --transient-local Set Durability QoS as transient local" << std::endl;
104105
std::cout << " (Default: Volatile)" << std::endl;
106+
std::cout << " -s <num>, --samples <num> Number of samples to send/receive" << std::endl;
105107
std::cout << "Publisher options:" << std::endl;
106-
std::cout << " -s <num>, --samples <num> Number of samples to send" << std::endl;
107108
std::cout << " (Default: 0 [unlimited])" << std::endl;
108109
std::cout << " -i <num>, --interval <num> Time between samples in milliseconds" << std::endl;
109110
std::cout << " --reader-filters <num> Set the maximum number of readers that the" << std::endl;
@@ -191,9 +192,7 @@ class CLIParser
191192
}
192193
else if (config.entity == CLIParser::EntityKind::SUBSCRIBER)
193194
{
194-
EPROSIMA_LOG_ERROR(CLI_PARSER,
195-
"samples option option can only be used with the Publisher");
196-
print_help(EXIT_FAILURE);
195+
config.sub_config.samples = static_cast<uint16_t>(input);
197196
}
198197
else
199198
{

examples/cpp/content_filter/SubscriberApp.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ SubscriberApp::SubscriberApp(
4646
, topic_(nullptr)
4747
, reader_(nullptr)
4848
, type_(new HelloWorldPubSubType())
49+
, received_samples_(0)
50+
, samples_(config.samples)
4951
, filter_topic_(nullptr)
5052
, stop_(false)
5153
{
@@ -180,6 +182,11 @@ void SubscriberApp::on_subscription_matched(
180182
else if (info.current_count_change == -1)
181183
{
182184
std::cout << "Subscriber unmatched." << std::endl;
185+
186+
if (received_samples_ > 0 && (received_samples_ >= samples_))
187+
{
188+
stop();
189+
}
183190
}
184191
// Non-valid option
185192
else
@@ -199,7 +206,7 @@ void SubscriberApp::on_data_available(
199206
// Some samples only update the instance state. Only if it is a valid sample (with data)
200207
if ((info.instance_state == ALIVE_INSTANCE_STATE) && info.valid_data)
201208
{
202-
samples_++;
209+
received_samples_++;
203210
// Print structure data
204211
std::cout << "Message: '" << hello_.message() << "' with index: '" << hello_.index()
205212
<< "' RECEIVED" << std::endl;

examples/cpp/content_filter/SubscriberApp.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class SubscriberApp : public Application, public DataReaderListener
8787

8888
TypeSupport type_;
8989

90+
uint16_t received_samples_;
91+
9092
uint16_t samples_;
9193

9294
//! DDS ContentFilteredTopic pointer

examples/cpp/rtps/CLIParser.hpp

+39-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class CLIParser
4747
{
4848
CLIParser::EntityKind entity = CLIParser::EntityKind::UNDEFINED;
4949
uint16_t samples = 0;
50+
uint16_t matched = 1;
5051
};
5152

5253
/**
@@ -59,7 +60,7 @@ class CLIParser
5960
static void print_help(
6061
uint8_t return_code)
6162
{
62-
std::cout << "Usage: rtps <entity> [options]" << std::endl;
63+
std::cout << "Usage: rtps <entity> [options]" << std::endl;
6364
std::cout << "" << std::endl;
6465
std::cout << "Entities:" << std::endl;
6566
std::cout << " writer Run a RTPS Writer entity" << std::endl;
@@ -70,6 +71,9 @@ class CLIParser
7071
std::cout << " -s <num>, --samples <num> Number of samples to send or receive" << std::endl;
7172
std::cout << " [0 <= <num> <= 65535]" << std::endl;
7273
std::cout << " (Default: 0 [unlimited])" << std::endl;
74+
std::cout << "Writer options:" << std::endl;
75+
std::cout << " -m, --matched Number of readers to match" << std::endl;
76+
std::cout << " before start publishing (Default: 1)" << std::endl;
7377
std::exit(return_code);
7478
}
7579

@@ -152,6 +156,40 @@ class CLIParser
152156
print_help(EXIT_FAILURE);
153157
}
154158
}
159+
else if (arg == "-m" || arg == "--matched")
160+
{
161+
try
162+
{
163+
int input = std::stoi(argv[++i]);
164+
if (input < std::numeric_limits<std::uint16_t>::min() ||
165+
input > std::numeric_limits<std::uint16_t>::max())
166+
{
167+
throw std::out_of_range("matched argument out of range");
168+
}
169+
else
170+
{
171+
if (config.entity == CLIParser::EntityKind::WRITER)
172+
{
173+
config.matched = static_cast<uint16_t>(input);
174+
}
175+
else
176+
{
177+
EPROSIMA_LOG_ERROR(CLI_PARSER, "matched can only be used with the writer entity");
178+
print_help(EXIT_FAILURE);
179+
}
180+
}
181+
}
182+
catch (const std::invalid_argument& e)
183+
{
184+
EPROSIMA_LOG_ERROR(CLI_PARSER, "invalid sample argument for " + arg + ": " + e.what());
185+
print_help(EXIT_FAILURE);
186+
}
187+
catch (const std::out_of_range& e)
188+
{
189+
EPROSIMA_LOG_ERROR(CLI_PARSER, "sample argument out of range for " + arg + ": " + e.what());
190+
print_help(EXIT_FAILURE);
191+
}
192+
}
155193
else
156194
{
157195
EPROSIMA_LOG_ERROR(CLI_PARSER, "unknown option " + arg);

examples/cpp/rtps/WriterApp.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ WriterApp::WriterApp(
7171
, rtps_writer_(nullptr)
7272
, writer_history_(nullptr)
7373
, matched_(0)
74+
, expected_matches_(config.matched)
7475
, stop_(false)
7576
, data_(new HelloWorld)
7677
{
@@ -210,7 +211,7 @@ bool WriterApp::add_change_to_history()
210211
terminate_cv_.wait(matched_lock, [&]()
211212
{
212213
// at least one has been discovered
213-
return ((matched_ > 0) || is_stopped());
214+
return ((matched_ >= expected_matches_) || is_stopped());
214215
});
215216

216217
bool ret = false;

examples/cpp/rtps/WriterApp.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ class WriterApp : public Application, public WriterListener
8686

8787
int16_t matched_;
8888

89+
uint16_t expected_matches_;
90+
8991
std::atomic<bool> stop_;
9092

9193
mutable std::mutex terminate_cv_mtx_;

test/examples/CMakeLists.txt

+76
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ if(UNIX AND NOT(APPLE) AND NOT(QNXNTO) AND NOT(ANDROID))
3939
set(SHELL_EXECUTABLE ${BASH_EXECUTABLE})
4040
set(DOCKER_IMAGE_NAME "ubuntu:22.04")
4141

42+
<<<<<<< HEAD
43+
=======
44+
set(PROJECT_BINARY_DIR_COMPOSE_VOLUME "${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}")
45+
set(fastcdr_LIB_DIR_COMPOSE_VOLUME "${fastcdr_LIB_DIR}:${fastcdr_LIB_DIR}")
46+
set(CMAKE_INSTALL_PREFIX_COMPOSE_VOLUME "${CMAKE_INSTALL_PREFIX}:${CMAKE_INSTALL_PREFIX}")
47+
48+
set(PATH_ENVIRONMENT_VARIABLE_COMPOSE "LD_LIBRARY_PATH: ${PROJECT_BINARY_DIR}/src/cpp:${fastcdr_LIB_DIR}")
49+
if (TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH)
50+
set(PATH_ENVIRONMENT_VARIABLE_COMPOSE "${PATH_ENVIRONMENT_VARIABLE_COMPOSE}${TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH}")
51+
endif()
52+
set(EXAMPLE_PREFIX_DIR_COMPOSE "${PROJECT_BINARY_DIR}/examples/cpp")
53+
set(EXAMPLE_SUFFIX_DIR_COMPOSE "")
54+
set(FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE "${PROJECT_BINARY_DIR}/examples/cpp")
55+
set(COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE "$\${EXAMPLE_DIR}")
56+
set(COMMAND_CONCATENATE_COMPOSE "&")
57+
set(COMMAND_BACKGROUND_JOB_COMPOSE "")
58+
59+
set(SUB_ADDITIONAL_ARGS_COMPOSE "$\${SUB_ADDITIONAL_ARGS_COMPOSE}")
60+
set(PUB_ADDITIONAL_ARGS_COMPOSE "$\${PUB_ADDITIONAL_ARGS_COMPOSE}")
61+
set(SPLIT_ARGS_COMPOSE "")
62+
63+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))
4264
# Windows configurations
4365
elseif(WIN32)
4466
# Find pwsh
@@ -53,16 +75,70 @@ elseif(WIN32)
5375
# We don't know which docker image to use for Windows yet
5476
message(FATAL_ERROR "Windows not supported yet")
5577

78+
<<<<<<< HEAD
79+
=======
80+
# Ensure drives inside docker are mounted in C: drive
81+
string(REGEX REPLACE ".:" "C:" CMAKE_INSTALL_PREFIX_C ${CMAKE_INSTALL_PREFIX})
82+
string(REGEX REPLACE ".:" "C:" PROJECT_BINARY_DIR_C ${PROJECT_BINARY_DIR})
83+
string(REGEX REPLACE ".:" "C:" fastcdr_INSTALL_DIR_C ${fastcdr_INSTALL_DIR})
84+
85+
set(PROJECT_BINARY_DIR_COMPOSE_VOLUME "${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR_C}")
86+
set(fastcdr_LIB_DIR_COMPOSE_VOLUME "${fastcdr_INSTALL_DIR}/bin:${fastcdr_INSTALL_DIR_C}/bin")
87+
set(CMAKE_INSTALL_PREFIX_COMPOSE_VOLUME "${CMAKE_INSTALL_PREFIX}/bin:${CMAKE_INSTALL_PREFIX_C}/bin")
88+
89+
set(PATH_ENVIRONMENT_VARIABLE_COMPOSE "PATH: C:/Program Files/OpenSSL-Win64;${CMAKE_INSTALL_PREFIX_C}/bin;${fastcdr_INSTALL_DIR_C}/bin;C:/Windows/System32;C:/Windows/System32/downlevel;")
90+
set(EXAMPLE_PREFIX_DIR_COMPOSE "${PROJECT_BINARY_DIR_C}/examples/cpp")
91+
if (CMAKE_BUILD_TYPE)
92+
set(EXAMPLE_SUFFIX_DIR_COMPOSE "${CMAKE_BUILD_TYPE}")
93+
else()
94+
set(EXAMPLE_SUFFIX_DIR_COMPOSE "Release")
95+
endif()
96+
set(FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE "${PROJECT_BINARY_DIR_C}/examples/cpp")
97+
set(COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE "& $\$Env:EXAMPLE_DIR")
98+
set(COMMAND_CONCATENATE_COMPOSE "&\" \"")
99+
set(COMMAND_BACKGROUND_JOB_COMPOSE "; Receive-Job 1 -Wait")
100+
101+
set(SUB_ADDITIONAL_ARGS_COMPOSE "$\$Env:SUB_ADDITIONAL_ARGS_COMPOSE")
102+
set(PUB_ADDITIONAL_ARGS_COMPOSE "$\$Env:PUB_ADDITIONAL_ARGS_COMPOSE")
103+
set(SPLIT_ARGS_COMPOSE ".split(' ')")
104+
105+
set(WIN_DOCKERFILE ${CMAKE_CURRENT_LIST_DIR}/windows/Dockerfile)
106+
# Generate image for testing
107+
add_custom_target(
108+
windows_docker_image_testing_generation
109+
ALL
110+
# Launch the docker build command using the build context.
111+
COMMAND ${DOCKER_EXECUTABLE} build
112+
--tag ${DOCKER_IMAGE_NAME}
113+
--file ${WIN_DOCKERFILE}
114+
${CMAKE_CURRENT_LIST_DIR}
115+
COMMENT "Creating windows image for testing..." VERBATIM
116+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
117+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))
56118
# Unsupported platform
57119
else()
58120
message(FATAL_ERROR "Unsupported platform")
59121
endif()
60122

123+
<<<<<<< HEAD
61124
# Configure TinyXML2 library path if installed in user library path
62125
if(NOT (TINYXML2_FROM_SOURCE OR TINYXML2_FROM_THIRDPARTY))
63126
get_filename_component(TINYXML2_LIB_DIR ${TINYXML2_LIBRARY} DIRECTORY)
64127
set(TINYXML2_LIB_DIR_COMPOSE_VOLUME "- ${TINYXML2_LIB_DIR}:${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/fastdds:ro")
65128
set(TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH ":${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/fastdds")
129+
=======
130+
if(WIN32)
131+
# Temporarily, test hello world
132+
file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
133+
${CMAKE_CURRENT_SOURCE_DIR}/test_custom_payload_pool.py
134+
${CMAKE_CURRENT_SOURCE_DIR}/test_hello_world.py
135+
${CMAKE_CURRENT_SOURCE_DIR}/test_rtps.py
136+
${CMAKE_CURRENT_SOURCE_DIR}/test_flow_control.py
137+
${CMAKE_CURRENT_SOURCE_DIR}/test_content_filter.py)
138+
else()
139+
# Find all pytest files for testing
140+
file(GLOB examples_python_tests RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.py)
141+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))
66142
endif()
67143

68144
# Find all pytest files for testing

test/examples/content_filter.compose.yml

+7
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ services:
2121
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
2222
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
2323
environment:
24+
<<<<<<< HEAD
2425
# TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows
2526
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@
2627
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/content_filter@FILE_EXTENSION@
2728
SUBSCRIBER_ADDITIONAL_ARGUMENTS: ${SUB_ARGS}
2829
command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/content_filter@FILE_EXTENSION@ subscriber $${SUBSCRIBER_ADDITIONAL_ARGUMENTS} --lower-bound 4 --upper-bound 8 --reliable --transient-local & $${EXAMPLE_DIR}/content_filter@FILE_EXTENSION@ publisher --samples 15 --interval 100 --reliable --transient-local"
30+
=======
31+
@PATH_ENVIRONMENT_VARIABLE_COMPOSE@
32+
EXAMPLE_DIR: @EXAMPLE_PREFIX_DIR_COMPOSE@/content_filter/@EXAMPLE_SUFFIX_DIR_COMPOSE@
33+
SUB_ADDITIONAL_ARGS_COMPOSE: ${SUB_ARGS}
34+
command: @SHELL_EXECUTABLE@ -c "@COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/content_filter@FILE_EXTENSION@ subscriber @SUB_ADDITIONAL_ARGS_COMPOSE@@SPLIT_ARGS_COMPOSE@ --lower-bound 4 --upper-bound 8 --reliable --transient-local @COMMAND_CONCATENATE_COMPOSE@ @COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/content_filter@FILE_EXTENSION@ publisher --samples 15 --interval 100 --reliable --transient-local@COMMAND_BACKGROUND_JOB_COMPOSE@"
35+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))

test/examples/custom_payload_pool.compose.yml

+6
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ services:
2121
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
2222
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
2323
environment:
24+
<<<<<<< HEAD
2425
# TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows
2526
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@
2627
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/custom_payload_pool
2728
command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/custom_payload_pool@FILE_EXTENSION@ subscriber --samples 10"
29+
=======
30+
@PATH_ENVIRONMENT_VARIABLE_COMPOSE@
31+
EXAMPLE_DIR: @EXAMPLE_PREFIX_DIR_COMPOSE@/custom_payload_pool/@EXAMPLE_SUFFIX_DIR_COMPOSE@
32+
command: @SHELL_EXECUTABLE@ -c "@COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/custom_payload_pool@FILE_EXTENSION@ subscriber --samples 10"
33+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))
2834

2935
publisher:
3036
image: @DOCKER_IMAGE_NAME@

test/examples/rtps.compose.yml

+13
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,16 @@ services:
4646
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
4747
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
4848
environment:
49+
<<<<<<< HEAD
4950
# TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows
5051
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@
5152
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/rtps
5253
command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/rtps@FILE_EXTENSION@ writer --samples 10"
54+
=======
55+
@PATH_ENVIRONMENT_VARIABLE_COMPOSE@
56+
EXAMPLE_DIR: @EXAMPLE_PREFIX_DIR_COMPOSE@/rtps/@EXAMPLE_SUFFIX_DIR_COMPOSE@
57+
command: @SHELL_EXECUTABLE@ -c "@COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/rtps@FILE_EXTENSION@ writer --samples 10 --matched 2"
58+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))
5359
depends_on:
5460
- sub-rtps
5561
- sub-dds
@@ -61,11 +67,18 @@ services:
6167
- @fastcdr_LIB_DIR@:@fastcdr_LIB_DIR@
6268
@TINYXML2_LIB_DIR_COMPOSE_VOLUME@
6369
environment:
70+
<<<<<<< HEAD
6471
# TODO(eduponz): LD_LIBRARY_PATH is not the correct variable for Windows
6572
LD_LIBRARY_PATH: @PROJECT_BINARY_DIR@/src/cpp:@fastcdr_LIB_DIR@@TINYXML2_LIB_DIR_COMPOSE_LD_LIBRARY_PATH@
6673
EXAMPLE_DIR: @PROJECT_BINARY_DIR@/examples/cpp/hello_world
6774
FASTDDS_DEFAULT_PROFILES_FILE: @PROJECT_BINARY_DIR@/examples/cpp/rtps/hello_world_profile.xml
6875
command: @SHELL_EXECUTABLE@ -c "$${EXAMPLE_DIR}/hello_world@FILE_EXTENSION@ publisher --samples 10"
76+
=======
77+
@PATH_ENVIRONMENT_VARIABLE_COMPOSE@
78+
EXAMPLE_DIR: @EXAMPLE_PREFIX_DIR_COMPOSE@/hello_world/@EXAMPLE_SUFFIX_DIR_COMPOSE@
79+
FASTDDS_DEFAULT_PROFILES_FILE: @FASTDDS_DEFAULT_PROFILES_FILE_PREFIX_COMPOSE@/rtps/hello_world_profile.xml
80+
command: @SHELL_EXECUTABLE@ -c "@COMMAND_EXAMPLE_DIR_PREFIX_COMPOSE@/hello_world@FILE_EXTENSION@ publisher --samples 10 --matched 2"
81+
>>>>>>> 0deeb148b (Add `flow_control`, `rtps`, `custom_payload_pool` and `content_filter` to windows example ci testing (#5480))
6982
depends_on:
7083
- sub-rtps
7184
- sub-dds

test/examples/test_content_filter.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,30 @@
1515
import subprocess
1616
import pytest
1717
import re
18+
import os
1819

1920
custom_filter_test_cases = [
20-
('', True),
21-
('', False),
22-
('--reader-filters 0', True),
23-
('--reader-filters 0', False)]
24-
@pytest.mark.parametrize("pub_reader_filters, sub_custom_filter", custom_filter_test_cases)
25-
def test_content_filter(pub_reader_filters, sub_custom_filter):
21+
(True),
22+
(False)]
23+
@pytest.mark.parametrize("sub_custom_filter", custom_filter_test_cases)
24+
def test_content_filter(sub_custom_filter):
2625
"""."""
2726
ret = False
2827
out = ''
28+
29+
menv = dict(os.environ)
30+
2931
if (sub_custom_filter):
30-
command_prerequisites = 'PUB_ARGS="' + ' ' + pub_reader_filters + '" SUB_ARGS="' + ' --filter-kind custom" '
32+
menv["SUB_ARGS"] = "--filter-kind custom --samples 8"
3133
else:
32-
command_prerequisites = 'PUB_ARGS="' + ' ' + pub_reader_filters + '" SUB_ARGS="' + ' --filter-kind default" '
33-
34+
menv["SUB_ARGS"] = "--filter-kind default --samples 5"
35+
3436
try:
35-
out = subprocess.check_output(command_prerequisites +
36-
'@DOCKER_EXECUTABLE@ compose -f content_filter.compose.yml up',
37+
out = subprocess.check_output('"@DOCKER_EXECUTABLE@" compose -f content_filter.compose.yml up',
3738
stderr=subprocess.STDOUT,
3839
shell=True,
39-
timeout=30
40+
timeout=30,
41+
env=menv
4042
).decode().split('\n')
4143

4244
sent = 0

test/examples/test_custom_payload_pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_custom_payload_pool():
2020
out = ''
2121
try:
2222
out = subprocess.check_output(
23-
'@DOCKER_EXECUTABLE@ compose -f custom_payload_pool.compose.yml up',
23+
'"@DOCKER_EXECUTABLE@" compose -f custom_payload_pool.compose.yml up',
2424
stderr=subprocess.STDOUT,
2525
shell=True,
2626
timeout=30

test/examples/test_flow_control.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ def test_flow_control():
2020
out = ''
2121
try:
2222
out = subprocess.check_output(
23-
'@DOCKER_EXECUTABLE@ compose -f flow_control.compose.yml up',
23+
'"@DOCKER_EXECUTABLE@" compose -f flow_control.compose.yml up',
2424
stderr=subprocess.STDOUT,
2525
shell=True,
26-
timeout=30
26+
timeout=40
2727
).decode().split('\n')
2828

2929
sent = 0

0 commit comments

Comments
 (0)