Commit b663f3b7 authored by Marcin Siodelski's avatar Marcin Siodelski

[#717,!417] Extended mysql_cb test to insert subnet when there is no server.

parent 09186ce0
......@@ -1044,6 +1044,17 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getSubnet4) {
auto subnet = test_subnets_[0];
auto subnet2 = test_subnets_[2];
// An attempt to add a subnet to a non-existing server (server1) should fail.
EXPECT_THROW(cbptr_->createUpdateSubnet4(ServerSelector::MULTIPLE({ "server1", "server2" }),
subnet2),
DbOperationError);
// The subnet shouldn't have been added, even though one of the servers exists.
Subnet4Ptr returned_subnet;
ASSERT_NO_THROW(returned_subnet = cbptr_->getSubnet4(ServerSelector::ONE("server2"),
subnet2->getID()));
EXPECT_FALSE(returned_subnet);
// Insert two subnets, one for all servers and one for server2.
EXPECT_NO_THROW(cbptr_->createUpdateSubnet4(ServerSelector::ALL(), subnet));
{
......@@ -1142,8 +1153,7 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getSubnet4) {
EXPECT_NO_THROW(cbptr_->createUpdateSubnet4(ServerSelector::ONE("server2"), subnet2));
// Fetch again and verify.
auto returned_subnet = cbptr_->getSubnet4(ServerSelector::ONE("server2"),
subnet2->toText());
returned_subnet = cbptr_->getSubnet4(ServerSelector::ONE("server2"), subnet2->toText());
ASSERT_TRUE(returned_subnet);
EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
......
......@@ -1076,6 +1076,17 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getSubnet6) {
auto subnet = test_subnets_[0];
auto subnet2 = test_subnets_[2];
// An attempt to add a subnet to a non-existing server (server1) should fail.
EXPECT_THROW(cbptr_->createUpdateSubnet6(ServerSelector::MULTIPLE({ "server1", "server2" }),
subnet2),
DbOperationError);
// The subnet shouldn't have been added, even though one of the servers exists.
Subnet6Ptr returned_subnet;
ASSERT_NO_THROW(returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server2"),
subnet2->getID()));
EXPECT_FALSE(returned_subnet);
// Insert two subnets, one for all servers and one for server2.
EXPECT_NO_THROW(cbptr_->createUpdateSubnet6(ServerSelector::ALL(), subnet));
{
......@@ -1175,8 +1186,7 @@ TEST_F(MySqlConfigBackendDHCPv6Test, getSubnet6) {
EXPECT_NO_THROW(cbptr_->createUpdateSubnet6(ServerSelector::ONE("server2"), subnet2));
// Fetch again and verify.
auto returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server2"),
subnet2->toText());
returned_subnet = cbptr_->getSubnet6(ServerSelector::ONE("server2"), subnet2->toText());
ASSERT_TRUE(returned_subnet);
EXPECT_EQ(subnet2->toElement()->str(), returned_subnet->toElement()->str());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment