Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iox-#1030 Speed up posh tests #2020

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion doc/website/advanced/configuration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,33 @@ it as constructor argument to the RouDi instance.
In the cmake file entry of the custom RouDi executable you need to ensure that it
is **not** linking against `iceoryx_posh_config` to ensure using the static configuration.

An example of a static config can be found
```cpp
int main(int argc, char* argv[])
{
iox::RouDiConfig_t roudiConfig;

// create mempools
iox::mepoo::MePooConfig mepooConfig;
mepooConfig.addMemPool({128, 10000}); // payload in bytes, chunk count
mepooConfig.addMemPool({265, 10000});

auto currentGroup = iox::posix::PosixGroup::getGroupOfCurrentProcess();
roudiConfig.m_sharedMemorySegments.push_back({currentGroup.getName(), currentGroup.getName(), mepooConfig});

// configure the chunk count for the introspection; each introspection topic gets this number of chunks
roudiConfig.introspectionChunkCount = 10;

// configure the chunk count for the service discovery
roudiConfig.discoveryChunkCount = 10;

// create a roudi instance
iox::config::CmdLineParserConfigFileOption cmdLineParser;
IceOryxRouDiApp roudi(cmdLineParser.parse(argc, argv).expect("Valid CLI parameter"), roudiConfig);

// run roudi
return roudi.run();
}
```

A working example of a static config can be found
[here](../../../iceoryx_examples/iceperf/roudi_main_static_config.cpp).
2 changes: 2 additions & 0 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
- Fix `expected<void, Error>` is unusable due to `final` [\#1976](https://github.com/eclipse-iceoryx/iceoryx/issues/1976)
- MacOS tests that use `EXPECT_DEATH` stuck [#898](https://github.com/eclipse-iceoryx/iceoryx/issues/898)
- Remove `EXPECT_DEATH` [#1613](https://github.com/eclipse-iceoryx/iceoryx/issues/1613)
- ServiceDiscovery uses instrospection MemPools [#1359](https://github.com/eclipse-iceoryx/iceoryx/issues/1359)

**Refactoring:**

Expand Down Expand Up @@ -154,6 +155,7 @@
- Move `std::string` dependency from `iox::string` to `std_string_support.hpp` in `iceoryx_dust` [\#1612](https://github.com/eclipse-iceoryx/iceoryx/issues/1612)
- Better align `iox::expected` with `std::expected` [\#1969](https://github.com/eclipse-iceoryx/iceoryx/issues/1969)
- Use logger for "RouDi is ready for clients" message [\#1994](https://github.com/eclipse-iceoryx/iceoryx/issues/1994)
- Speed up posh tests [#1030](https://github.com/eclipse-iceoryx/iceoryx/issues/1030)

**Workflow:**

Expand Down
6 changes: 6 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ extern "C" {

#include "iceoryx_hoofs/error_handling/error_handling.hpp"
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp"
#include "iceoryx_posh/testing/roudi_gtest.hpp"

namespace
Expand All @@ -33,6 +34,11 @@ using namespace iox::testing;
class Chunk_test : public RouDi_GTest
{
public:
Chunk_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp() override
{
iox_runtime_init("hypnotoad");
Expand Down
6 changes: 6 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
#include "iceoryx_posh/runtime/posh_runtime.hpp"
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp"
#include "iceoryx_posh/testing/roudi_gtest.hpp"
#include <gtest/gtest.h>

Expand All @@ -35,6 +36,11 @@ using namespace iox::testing;
class iox_node_test : public RouDi_GTest
{
public:
iox_node_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp()
{
iox_runtime_init(m_runtimeName.c_str());
Expand Down
12 changes: 4 additions & 8 deletions iceoryx_binding_c/test/moduletests/test_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "iceoryx_posh/internal/popo/ports/publisher_port_roudi.hpp"
#include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp"
#include "iceoryx_posh/mepoo/mepoo_config.hpp"
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp"
#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp"

using namespace iox;
Expand Down Expand Up @@ -142,7 +143,7 @@ TEST(iox_pub_test_DeathTest, initPublisherWithNotInitializedPublisherOptionsTerm
TEST_F(iox_pub_test, initPublisherWithDefaultOptionsWorks)
{
::testing::Test::RecordProperty("TEST_ID", "d2e677cd-2fcc-47a2-80e6-2d08245b7c1a");
iox::roudi::RouDiEnvironment roudiEnv;
iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};

iox_runtime_init("hypnotoad");

Expand Down Expand Up @@ -464,13 +465,8 @@ TEST(iox_pub_options_test, publisherOptionsInitializationCheckReturnsFalseWithou
TEST(iox_pub_options_test, publisherOptionInitializationWithNullptrDoesNotCrash)
{
::testing::Test::RecordProperty("TEST_ID", "fe415d38-eaaf-466e-b7d8-d220612cb344");
EXPECT_EXIT(
{
iox_pub_options_init(nullptr);
exit(0);
},
::testing::ExitedWithCode(0),
".*");

IOX_EXPECT_NO_FATAL_FAILURE<iox::HoofsError>([&] { iox_pub_options_init(nullptr); });
}

} // namespace
6 changes: 6 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern "C" {
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp"
#include "iceoryx_posh/testing/roudi_gtest.hpp"

namespace
Expand All @@ -32,6 +33,11 @@ using namespace iox::testing;
class BindingC_Runtime_test : public RouDi_GTest
{
public:
BindingC_Runtime_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}

void SetUp()
{
}
Expand Down
24 changes: 24 additions & 0 deletions iceoryx_binding_c/test/moduletests/test_service_discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "iceoryx_hoofs/error_handling/error_handling.hpp"
#include "iceoryx_hoofs/testing/fatal_failure.hpp"
#include "iceoryx_posh/runtime/service_discovery.hpp"
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp"
#include "iceoryx_posh/testing/roudi_gtest.hpp"

using namespace iox;
Expand All @@ -39,6 +40,10 @@ using description_vector = vector<iox_service_description_t, MAX_FINDSERVICE_RES
class iox_service_discovery_test : public RouDi_GTest
{
public:
iox_service_discovery_test()
: RouDi_GTest(MinimalRouDiConfigBuilder().create())
{
}
void SetUp() override
{
iox_runtime_init("runtime");
Expand Down Expand Up @@ -76,6 +81,10 @@ TEST_F(iox_service_discovery_test,
FindServiceWithCallableAndContextDataWithNullptrsForServiceInstanceEventReturnsAllServices)
{
::testing::Test::RecordProperty("TEST_ID", "09a2cd6c-fba9-4b9d-af96-c5a6cc168d98");

// let the roudi discovery loop run at least once
InterOpWait();

iox_service_discovery_find_service_apply_callable_with_context_data(
sut, nullptr, nullptr, nullptr, findHandler, &searchResult, MessagingPattern_PUB_SUB);
for (const auto& service : searchResult)
Expand All @@ -94,6 +103,8 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableAndContextDataReturnsO
ASSERT_NE(publisher, nullptr);
const iox_service_description_t SERVICE_DESCRIPTION = iox_pub_get_service_description(publisher);

InterOpWait();

iox_service_discovery_find_service_apply_callable_with_context_data(sut,
SERVICE_DESCRIPTION.serviceString,
SERVICE_DESCRIPTION.instanceString,
Expand All @@ -112,6 +123,9 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableAndContextDataReturnsO
TEST_F(iox_service_discovery_test, FindServiceWithCallableWithNullptrsForServiceInstanceEventFindsCorrectServices)
{
::testing::Test::RecordProperty("TEST_ID", "ec565ca3-7494-42d7-9440-2000f1513759");

InterOpWait();

auto findHandler = [](const iox_service_description_t s) { EXPECT_THAT(s.instanceString, StrEq("RouDi_ID")); };
iox_service_discovery_find_service_apply_callable(
sut, nullptr, nullptr, nullptr, findHandler, MessagingPattern_PUB_SUB);
Expand All @@ -126,6 +140,8 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableReturnsFindsCorrectSer
auto* publisher = iox_pub_init(&storage, "service", "instance", "event", &options);
ASSERT_NE(publisher, nullptr);

InterOpWait();

auto findHandler = [](const iox_service_description_t s) {
EXPECT_THAT(s.serviceString, StrEq("service"));
EXPECT_THAT(s.instanceString, StrEq("instance"));
Expand All @@ -140,6 +156,9 @@ TEST_F(iox_service_discovery_test, FindServiceWithCallableReturnsFindsCorrectSer
TEST_F(iox_service_discovery_test, FindServiceWithNullptrsForServiceInstanceEventReturnsAllServices)
{
::testing::Test::RecordProperty("TEST_ID", "75b411d7-b8c7-42d5-8acd-3916fd172081");

InterOpWait();

const uint64_t SERVICE_CONTAINER_CAPACITY = 10U;
iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY];
uint64_t missedServices = 0U;
Expand Down Expand Up @@ -170,6 +189,8 @@ TEST_F(iox_service_discovery_test, FindServiceReturnsOfferedService)
ASSERT_NE(publisher, nullptr);
const iox_service_description_t SERVICE_DESCRIPTION = iox_pub_get_service_description(publisher);

InterOpWait();

const uint64_t SERVICE_CONTAINER_CAPACITY = 10U;
iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY];
uint64_t missedServices = 0U;
Expand All @@ -194,6 +215,9 @@ TEST_F(iox_service_discovery_test, FindServiceReturnsOfferedService)
TEST_F(iox_service_discovery_test, FindServiceReturnsCorrectNumberOfServicesWhenServiceContainerTooSmall)
{
::testing::Test::RecordProperty("TEST_ID", "01047b88-f257-447c-8c5e-9bef7c358433");

InterOpWait();

const uint64_t SERVICE_CONTAINER_CAPACITY = 3U;
iox_service_description_t serviceContainer[SERVICE_CONTAINER_CAPACITY];
uint64_t missedServices = 0U;
Expand Down
14 changes: 5 additions & 9 deletions iceoryx_binding_c/test/moduletests/test_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "iceoryx_posh/internal/popo/ports/subscriber_port_single_producer.hpp"
#include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp"
#include "iceoryx_posh/mepoo/mepoo_config.hpp"
#include "iceoryx_posh/testing/roudi_environment/minimal_roudi_config.hpp"
#include "iceoryx_posh/testing/roudi_environment/roudi_environment.hpp"
#include "mocks/wait_set_mock.hpp"

Expand Down Expand Up @@ -147,7 +148,7 @@ TEST_F(iox_sub_test, initSubscriberWithNotInitializedSubscriberOptionsTerminates
TEST_F(iox_sub_test, initSubscriberWithDefaultOptionsWorks)
{
::testing::Test::RecordProperty("TEST_ID", "40eaa006-4781-46cd-bde3-40fa7d572f29");
iox::roudi::RouDiEnvironment roudiEnv;
iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};

iox_runtime_init("hypnotoad");

Expand Down Expand Up @@ -404,7 +405,7 @@ TEST_F(iox_sub_test, hasDataTriggersWaitSetWithCorrectCallback)
TEST_F(iox_sub_test, deinitSubscriberDetachesTriggerFromWaitSet)
{
::testing::Test::RecordProperty("TEST_ID", "93e350fb-5430-43ff-982b-b43c6ae9b890");
iox::roudi::RouDiEnvironment roudiEnv;
iox::roudi::RouDiEnvironment roudiEnv{MinimalRouDiConfigBuilder().create()};
iox_runtime_init("hypnotoad");

iox_sub_storage_t storage;
Expand Down Expand Up @@ -557,13 +558,8 @@ TEST(iox_sub_options_test, subscriberOptionsInitializationCheckReturnsFalseWitho
TEST(iox_sub_options_test, subscriberOptionInitializationWithNullptrDoesNotCrash)
{
::testing::Test::RecordProperty("TEST_ID", "4c8eeb6e-5681-4551-865b-11b6a599edf5");
EXPECT_EXIT(
{
iox_sub_options_init(nullptr);
exit(0);
},
::testing::ExitedWithCode(0),
".*");

IOX_EXPECT_NO_FATAL_FAILURE<iox::HoofsError>([&] { iox_sub_options_init(nullptr); });
}

} // namespace
10 changes: 5 additions & 5 deletions iceoryx_examples/callbacks_in_c/ice_c_callbacks_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
#include <stdbool.h>
#include <stdio.h>

bool killswitch = false;
volatile bool keepRunning = true;

static void sigHandler(int f_sig)
static void sigHandler(int sig)
{
// ignore unused parameter
(void)f_sig;
killswitch = true;
(void)sig;
elBoberido marked this conversation as resolved.
Show resolved Hide resolved
keepRunning = false;
}

void sending(void)
Expand All @@ -47,7 +47,7 @@ void sending(void)
iox_pub_t publisherRight = iox_pub_init(&publisherRightStorage, "Radar", "FrontRight", "Counter", &options);

struct CounterTopic* userPayload;
for (uint32_t counter = 0U; !killswitch; ++counter)
for (uint32_t counter = 0U; keepRunning; ++counter)
{
if (counter % 3 == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <stdio.h>
#include <string.h>

bool keepRunning = true;
volatile bool keepRunning = true;

iox_user_trigger_t heartbeat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <stdio.h>
#include <string.h>

bool keepRunning = true;
volatile bool keepRunning = true;

static void sigHandler(int signalValue)
{
Expand Down
8 changes: 4 additions & 4 deletions iceoryx_examples/icedelivery_in_c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ iox_sub_t subscriber = iox_sub_init(&subscriberStorage, "Radar", "FrontLeft", "O
```

3. We receive samples in a loop and print the received data on the console as
long as the `killswitch` is not set to `true` by an external signal.
long as the `keepRunning` is not set to `false` by an external signal.

<!--[geoffrey][iceoryx_examples/icedelivery_in_c/ice_c_subscriber.c][receive and print data]-->
```c
while (!killswitch)
while (keepRunning)
{
if (SubscribeState_SUBSCRIBED == iox_sub_get_subscription_state(subscriber))
{
Expand Down Expand Up @@ -132,15 +132,15 @@ iox_pub_storage_t publisherStorage;
iox_pub_t publisher = iox_pub_init(&publisherStorage, "Radar", "FrontLeft", "Object", &options);
```

3. Until an external signal sets `killswitch` to `true`, we will send an
3. Until an external signal sets `keepRunning` to `false`, we will send an
incrementing number to all subscribers in every iteration and print the
value of that number to the console.

<!--[geoffrey][iceoryx_examples/icedelivery_in_c/ice_c_publisher.c][send and print number]-->
```c
double ct = 0.0;

while (!killswitch)
while (keepRunning)
{
void* userPayload = NULL;
if (AllocationResult_SUCCESS == iox_pub_loan_chunk(publisher, &userPayload, sizeof(struct RadarObject)))
Expand Down
6 changes: 3 additions & 3 deletions iceoryx_examples/icedelivery_in_c/ice_c_publisher.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
#include <stdbool.h>
#include <stdio.h>

bool killswitch = false;
volatile bool keepRunning = true;

static void sigHandler(int signalValue)
{
// Ignore unused variable warning
(void)signalValue;
// caught SIGINT or SIGTERM, now exit gracefully
killswitch = true;
keepRunning = false;
}

void sending(void)
Expand All @@ -53,7 +53,7 @@ void sending(void)
//! [send and print number]
double ct = 0.0;

while (!killswitch)
while (keepRunning)
{
void* userPayload = NULL;
if (AllocationResult_SUCCESS == iox_pub_loan_chunk(publisher, &userPayload, sizeof(struct RadarObject)))
Expand Down
Loading
Loading