mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 04:41:35 +08:00
Server test extension
This commit is contained in:
@@ -875,6 +875,12 @@ public:
|
|||||||
}
|
}
|
||||||
return LazyConstructor<LogEntryInfo>();
|
return LazyConstructor<LogEntryInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::Index getNumAllocations() const
|
||||||
|
{
|
||||||
|
// Remember that index zero contains a special-purpose entry that doesn't count as allocation
|
||||||
|
return persistent_state_.getLog().getLastIndex();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,6 +300,8 @@ public:
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log::Index getNumAllocations() const { return raft_core_.getNumAllocations(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ TEST(DynamicNodeIDServer, Main)
|
|||||||
|
|
||||||
ASSERT_LE(0, server.init(own_unique_id, 1));
|
ASSERT_LE(0, server.init(own_unique_id, 1));
|
||||||
|
|
||||||
|
ASSERT_EQ(0, server.getNumAllocations());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Client
|
* Client
|
||||||
*/
|
*/
|
||||||
@@ -168,6 +170,8 @@ TEST(DynamicNodeIDServer, Main)
|
|||||||
|
|
||||||
ASSERT_TRUE(client.isAllocationComplete());
|
ASSERT_TRUE(client.isAllocationComplete());
|
||||||
ASSERT_EQ(PreferredNodeID, client.getAllocatedNodeID());
|
ASSERT_EQ(PreferredNodeID, client.getAllocatedNodeID());
|
||||||
|
|
||||||
|
ASSERT_EQ(2, server.getNumAllocations()); // Server's own node ID + client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user