Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ namespace internal
/// @brief This is initially some ID provided by the Control Client library. When received
/// by Control Client handler additional information is added - the state manager
/// process originating the request. This can be given in the form of a function
/// group index and process index.
/// group index and process identifier.
/// When the Control Client library receives a response, it must be able to extract
/// the client ID, ignoring the state manager process identification.
struct ControlClientID final
{
uint16_t process_group_index_; ///< Process group containing the state manager process
uint16_t process_index_; ///< The process within the process group
uint32_t future_id_; ///< ID to match request and response
ControlClientID() : process_group_index_(0), process_index_(0), future_id_(0)
uint16_t process_group_index_; ///< Process group containing the state manager process
IdentifierHash process_identifier_; ///< The process within the process group
uint32_t future_id_; ///< ID to match request and response
ControlClientID() : process_group_index_(0), process_identifier_(""), future_id_(0)
{
} ///< For use by Control Client
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cc_library(
strip_include_prefix = "/score/launch_manager/src/daemon/src/process_group_manager/details",
visibility = ["//score:__subpackages__"],
deps = [
"//score/launch_manager/src/daemon/src/common:identifier_hash",
"@score_baselibs//score/language/futurecpp",
],
)
Expand Down Expand Up @@ -242,6 +243,7 @@ cc_library(
strip_include_prefix = "/score/launch_manager/src/daemon/src/process_group_manager/details",
visibility = ["//score/launch_manager/src/daemon/src/process_group_manager:__pkg__"],
deps = [
":component_of",
":dependency_graph",
"//score/launch_manager/src/daemon/src/common:constants",
"//score/launch_manager/src/daemon/src/common/concurrency:fixed_size_queue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ namespace score::mw::lifecycle::internal
/// @brief A node finished activating successfully.
struct [[nodiscard]] ActivationSuccessful
{
uint32_t node_index;
IdentifierHash node_identifier;
};

/// @brief A node failed to activate.
struct [[nodiscard]] ActivationFailed
{
uint32_t node_index;
IdentifierHash node_identifier;
IComponent::ComponentError reason;
};

/// @brief A node finished deactivating.
struct [[nodiscard]] DeactivationComplete
{
uint32_t node_index;
IdentifierHash node_identifier;
};

/// @brief A node terminated without having been requested to.
struct [[nodiscard]] UnexpectedTermination
{
uint32_t node_index;
IdentifierHash node_identifier;
};

/// @brief A job was queued but cancelled by the time it was processed
struct [[nodiscard]] JobSkipped
{
uint32_t node_index;
IdentifierHash node_identifier;
};

/// @brief Alive supervision has failed for the given process identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ TEST_F(ComponentEventQueueTest, WaitForEventsReturnsFalseOnEmptyQueue)
TEST_F(ComponentEventQueueTest, WaitForEventsReturnsTrueAfterPush)
{
RecordProperty("Description", "Verify waitForEvents returns true once an event has been pushed.");
EXPECT_TRUE(queue_.push(ActivationSuccessful{7U}));
EXPECT_TRUE(queue_.push(ActivationSuccessful{IdentifierHash{"process"}}));
EXPECT_TRUE(queue_.waitForEvents(std::chrono::milliseconds{0}));
}

Expand All @@ -53,13 +53,14 @@ TEST_F(ComponentEventQueueTest, GetNextEventReturnsNulloptWhenEmpty)
TEST_F(ComponentEventQueueTest, GetNextEventReturnsPushedEventWithPayloadIntact)
{
RecordProperty("Description", "Verify a pushed event is returned by getNextEvent with its payload preserved.");
EXPECT_TRUE(queue_.push(ActivationFailed{3U, IComponent::ComponentError::kErrorBeforeReady}));
const IdentifierHash process_identifier{"payload"};
EXPECT_TRUE(queue_.push(ActivationFailed{process_identifier, IComponent::ComponentError::kErrorBeforeReady}));

auto event = queue_.getNextEvent();
ASSERT_TRUE(event.has_value());
ASSERT_TRUE(std::holds_alternative<ActivationFailed>(*event));
const auto& failed = std::get<ActivationFailed>(*event);
EXPECT_EQ(failed.node_index, 3U);
EXPECT_EQ(failed.node_identifier, process_identifier);
EXPECT_EQ(failed.reason, IComponent::ComponentError::kErrorBeforeReady);
}

Expand All @@ -82,7 +83,7 @@ TEST_F(ComponentEventQueueTest, GetNextEventReturnsSupervisionFailureWithPayload
TEST_F(ComponentEventQueueTest, GetOverflowStaysFalseUnderNormalUsage)
{
RecordProperty("Description", "Verify getOverflow() stays false when events are pushed and drained normally.");
EXPECT_TRUE(queue_.push(ActivationSuccessful{1U}));
EXPECT_TRUE(queue_.push(ActivationSuccessful{IdentifierHash{"process"}}));
static_cast<void>(queue_.getNextEvent());
EXPECT_FALSE(queue_.getOverflow());
}
Expand All @@ -95,13 +96,13 @@ TEST_F(ComponentEventQueueTest, GetOverflowBecomesTrueOnceQueueIsFull)
"mirroring how ProcessGroupManager::run() detects lost events.");
for (std::size_t i = 0U; i < queue_.capacity(); ++i)
{
EXPECT_TRUE(queue_.push(ActivationSuccessful{static_cast<uint32_t>(i)}));
EXPECT_TRUE(queue_.push(ActivationSuccessful{IdentifierHash{"process"}}));
}
EXPECT_FALSE(queue_.getOverflow());

// One more push while the queue is already at capacity and nobody is draining it: this
// push is dropped immediately, flagging overflow.
EXPECT_FALSE(queue_.push(ActivationSuccessful{9999U}));
EXPECT_FALSE(queue_.push(ActivationSuccessful{IdentifierHash{"process"}}));
EXPECT_TRUE(queue_.getOverflow());
}

Expand All @@ -111,7 +112,7 @@ TEST_F(ComponentEventQueueTest, StopFailsWaitForEventsOnEmptyQueue)
"Description",
"Verify stop() causes a subsequently-called waitForEvents() to return false, even if there's an event in the "
"queue");
EXPECT_TRUE(queue_.push(ActivationSuccessful{1}));
EXPECT_TRUE(queue_.push(ActivationSuccessful{IdentifierHash{"process"}}));
queue_.stop();
EXPECT_FALSE(queue_.waitForEvents(std::chrono::milliseconds{0}));
}
Expand All @@ -122,7 +123,7 @@ TEST_F(ComponentEventQueueTest, GetNextEventStillDrainsQueuedEventsAfterStop)
"Description",
"Verify that events pushed before stop() was called are not silently discarded -- "
"getNextEvent() must still be able to drain them during shutdown.");
EXPECT_TRUE(queue_.push(ActivationSuccessful{1U}));
EXPECT_TRUE(queue_.push(ActivationSuccessful{IdentifierHash{"process"}}));
queue_.stop();

auto event = queue_.getNextEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace score::mw::lifecycle::internal
{

/// @brief Returns the IComponent reference from a variant type
/// @details All types in the variant must implement the IComponent interface.
inline IComponent& componentOf(std::variant<ProcessInfoNode, RunTarget>& node)
Expand All @@ -32,6 +33,13 @@ inline IComponent& componentOf(std::variant<ProcessInfoNode, RunTarget>& node)
node);
}

/// @brief Returns the IComponent reference from an interface pointer. Useful for a template class that may take a
/// variant or a generic interface
inline IComponent& componentOf(IComponent* node)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really needed? seems a bit unnecessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for transition_UT, it defines its own componentOf method to override the std::variant one. I could leave this change out but I thought it made the UT easier to understand. Can be removed after #427 as well.

{
return *node;
}

} // namespace score::mw::lifecycle::internal

#endif // SCORE_LCM_COMPONENT_OF_HPP_INCLUDED
Loading
Loading