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

Fix EdgeHolder from incorrectly reporting an active connection #402

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion cpp/mrc/include/mrc/edge/edge_holder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class EdgeHolder

void release_edge_connection()
{
m_owned_edge_lifetime.reset();
m_connected_edge.reset();
}

Expand Down
38 changes: 36 additions & 2 deletions cpp/mrc/tests/test_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

#include "mrc/channel/buffered_channel.hpp" // IWYU pragma: keep
#include "mrc/channel/forward.hpp"
#include "mrc/edge/edge.hpp" // for Edge
#include "mrc/edge/edge_builder.hpp"
#include "mrc/edge/edge_channel.hpp"
#include "mrc/edge/edge_holder.hpp" // for EdgeHolder
#include "mrc/edge/edge_readable.hpp"
#include "mrc/edge/edge_writable.hpp"
#include "mrc/node/generic_source.hpp"
Expand All @@ -40,7 +42,6 @@
#include <rxcpp/rx.hpp> // for observable_member

#include <functional>
#include <map>
#include <memory>
#include <ostream>
#include <stdexcept>
Expand All @@ -57,7 +58,7 @@ using namespace std::chrono_literals;

TEST_CLASS(Edges);

using TestEdgesDeathTest = TestEdges; // NOLINT(readability-identifier-naming)
using TestEdgesDeathTest = TestEdges; // NOLINT(readability-identifier-naming)p
dagardner-nv marked this conversation as resolved.
Show resolved Hide resolved

namespace mrc::node {

Expand Down Expand Up @@ -996,4 +997,37 @@ TEST_F(TestEdges, EdgeTapWithSpliceRxComponent)

EXPECT_TRUE(node->stream_fn_called);
}

template <typename T>
class TestEdgeHolder : public edge::EdgeHolder<T>
{
public:
bool has_active_connection() const
{
return this->check_active_connection(false);
}

void call_release_edge_connection()
{
this->release_edge_connection();
}

void call_init_owned_edge(std::shared_ptr<edge::Edge<T>> edge)
{
this->init_owned_edge(std::move(edge));
}
};

TEST_F(TestEdges, EdgeHolderIsConnected)
{
TestEdgeHolder<int> edge_holder;
auto edge = std::make_shared<edge::Edge<int>>();
EXPECT_FALSE(edge_holder.has_active_connection());

edge_holder.call_init_owned_edge(edge);
EXPECT_FALSE(edge_holder.has_active_connection());

edge_holder.call_release_edge_connection();
EXPECT_FALSE(edge_holder.has_active_connection());
}
} // namespace mrc
Loading