mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[#1041] Extended statusGet unittests
The uptime, reload and pid returned are validated.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <process/testutils/d_test_stubs.h>
|
||||
#include <boost/pointer_cast.hpp>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace isc::agent;
|
||||
@@ -676,8 +677,24 @@ TEST_F(CtrlAgentControllerTest, statusGet) {
|
||||
EXPECT_EQ(0, result->intValue());
|
||||
ConstElementPtr arguments = response->get("arguments");
|
||||
ASSERT_EQ(Element::map, arguments->getType());
|
||||
EXPECT_TRUE(arguments->contains("pid"));
|
||||
EXPECT_TRUE(arguments->contains("uptime"));
|
||||
|
||||
// The returned pid should be the pid of our process.
|
||||
auto found_pid = arguments->get("pid");
|
||||
ASSERT_TRUE(found_pid);
|
||||
EXPECT_EQ(static_cast<int64_t>(getpid()), found_pid->intValue());
|
||||
|
||||
// It is hard to check the actual uptime (and reload) as it is based
|
||||
// on current time. Let's just make sure it is within a reasonable
|
||||
// range.
|
||||
auto found_uptime = arguments->get("uptime");
|
||||
ASSERT_TRUE(found_uptime);
|
||||
EXPECT_LE(found_uptime->intValue(), 5);
|
||||
EXPECT_GE(found_uptime->intValue(), 0);
|
||||
|
||||
auto found_reload = arguments->get("reload");
|
||||
ASSERT_TRUE(found_reload);
|
||||
EXPECT_LE(found_reload->intValue(), 5);
|
||||
EXPECT_GE(found_reload->intValue(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace isc;
|
||||
@@ -632,9 +633,24 @@ TEST_F(CtrlChannelD2Test, statusGet) {
|
||||
EXPECT_EQ(0, result->intValue());
|
||||
ConstElementPtr arguments = response->get("arguments");
|
||||
ASSERT_EQ(Element::map, arguments->getType());
|
||||
EXPECT_TRUE(arguments->contains("pid"));
|
||||
// launch is not called so we have only reload, not uptime.
|
||||
EXPECT_TRUE(arguments->contains("reload"));
|
||||
|
||||
// The returned pid should be the pid of our process.
|
||||
auto found_pid = arguments->get("pid");
|
||||
ASSERT_TRUE(found_pid);
|
||||
EXPECT_EQ(static_cast<int64_t>(getpid()), found_pid->intValue());
|
||||
|
||||
// It is hard to check the actual reload time as it is based
|
||||
// on current time. Let's just make sure it is within a reasonable
|
||||
// range.
|
||||
auto found_reload = arguments->get("reload");
|
||||
ASSERT_TRUE(found_reload);
|
||||
EXPECT_LE(found_reload->intValue(), 5);
|
||||
EXPECT_GE(found_reload->intValue(), 0);
|
||||
|
||||
/// @todo uptime is not available in this test, because the launch()
|
||||
/// function is not called. This is not critical to test here,
|
||||
/// because the same logic is tested for CA and in that case the
|
||||
/// uptime is tested.
|
||||
}
|
||||
|
||||
// Tests if the server returns its configuration using config-get.
|
||||
|
@@ -1049,8 +1049,24 @@ TEST_F(CtrlChannelDhcpv4SrvTest, statusGet) {
|
||||
EXPECT_EQ(0, result->intValue());
|
||||
ConstElementPtr arguments = response->get("arguments");
|
||||
ASSERT_EQ(Element::map, arguments->getType());
|
||||
EXPECT_TRUE(arguments->contains("pid"));
|
||||
EXPECT_TRUE(arguments->contains("uptime"));
|
||||
|
||||
// The returned pid should be the pid of our process.
|
||||
auto found_pid = arguments->get("pid");
|
||||
ASSERT_TRUE(found_pid);
|
||||
EXPECT_EQ(static_cast<int64_t>(getpid()), found_pid->intValue());
|
||||
|
||||
// It is hard to check the actual uptime (and reload) as it is based
|
||||
// on current time. Let's just make sure it is within a reasonable
|
||||
// range.
|
||||
auto found_uptime = arguments->get("uptime");
|
||||
ASSERT_TRUE(found_uptime);
|
||||
EXPECT_LE(found_uptime->intValue(), 5);
|
||||
EXPECT_GE(found_uptime->intValue(), 0);
|
||||
|
||||
auto found_reload = arguments->get("reload");
|
||||
ASSERT_TRUE(found_reload);
|
||||
EXPECT_LE(found_reload->intValue(), 5);
|
||||
EXPECT_GE(found_reload->intValue(), 0);
|
||||
}
|
||||
|
||||
// This test verifies that the DHCP server handles config-backend-pull command
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <thread>
|
||||
|
||||
@@ -941,8 +942,24 @@ TEST_F(CtrlChannelDhcpv6SrvTest, statusGet) {
|
||||
EXPECT_EQ(0, result->intValue());
|
||||
ConstElementPtr arguments = response->get("arguments");
|
||||
ASSERT_EQ(Element::map, arguments->getType());
|
||||
EXPECT_TRUE(arguments->contains("pid"));
|
||||
EXPECT_TRUE(arguments->contains("uptime"));
|
||||
|
||||
// The returned pid should be the pid of our process.
|
||||
auto found_pid = arguments->get("pid");
|
||||
ASSERT_TRUE(found_pid);
|
||||
EXPECT_EQ(static_cast<int64_t>(getpid()), found_pid->intValue());
|
||||
|
||||
// It is hard to check the actual uptime (and reload) as it is based
|
||||
// on current time. Let's just make sure it is within a reasonable
|
||||
// range.
|
||||
auto found_uptime = arguments->get("uptime");
|
||||
ASSERT_TRUE(found_uptime);
|
||||
EXPECT_LE(found_uptime->intValue(), 5);
|
||||
EXPECT_GE(found_uptime->intValue(), 0);
|
||||
|
||||
auto found_reload = arguments->get("reload");
|
||||
ASSERT_TRUE(found_reload);
|
||||
EXPECT_LE(found_reload->intValue(), 5);
|
||||
EXPECT_GE(found_reload->intValue(), 0);
|
||||
}
|
||||
|
||||
// This test verifies that the DHCP server handles server-tag-get command
|
||||
|
Reference in New Issue
Block a user