summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/tests/cql_lease_mgr_unittest.cc
blob: baa2f7190f65c629c1f066aca0b63fdb1a065e9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
// Copyright (C) 2015 - 2016 Deutsche Telekom AG.
//
// Author: Razvan Becheriu <razvan.becheriu@qualitance.com>
// Author: Andrei Pavel <andrei.pavel@qualitance.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//           http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <config.h>

#include <asiolink/io_address.h>
#include <dhcpsrv/lease_mgr_factory.h>
#include <dhcpsrv/cql_connection.h>
#include <dhcpsrv/cql_lease_mgr.h>
#include <dhcpsrv/tests/test_utils.h>
#include <dhcpsrv/tests/generic_lease_mgr_unittest.h>
#include <dhcpsrv/testutils/cql_schema.h>
#include <exceptions/exceptions.h>

#include <gtest/gtest.h>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>

using namespace isc;
using namespace isc::asiolink;
using namespace isc::dhcp;
using namespace isc::dhcp::test;
using namespace std;

namespace {

/// @brief Test fixture class for testing Cassandra Lease Manager
///
/// Opens the database prior to each test and closes it afterwards.
/// All pending transactions are deleted prior to closure.

class CqlLeaseMgrTest : public GenericLeaseMgrTest {
public:
    /// @brief Constructor
    ///
    /// Deletes everything from the database and opens it.
    CqlLeaseMgrTest() {

        // Ensure schema is the correct one.
        destroyCqlSchema(false, true);
        createCqlSchema(false, true);

        // Connect to the database
        try {
            LeaseMgrFactory::create(validCqlConnectionString());
        } catch (...) {
            std::cerr << "*** ERROR: unable to open database. The test\n"
                         "*** environment is broken and must be fixed before\n"
                         "*** the CQL tests will run correctly.\n"
                         "*** The reason for the problem is described in the\n"
                         "*** accompanying exception output.\n";
            throw;
        }
        lmptr_ = &(LeaseMgrFactory::instance());
    }

    /// @brief Destructor
    ///
    /// Rolls back all pending transactions. The deletion of lmptr_ will close
    /// the database. Then reopen it and delete everything created by the test.
    virtual ~CqlLeaseMgrTest() {
        lmptr_->rollback();
        LeaseMgrFactory::destroy();
        destroyCqlSchema(false, true);
    }

    /// @brief Reopen the database
    ///
    /// Closes the database and re-open it. Anything committed should be
    /// visible.
    ///
    /// Parameter is ignored for CQL backend as the v4 and v6 leases share the
    /// same keyspace.
    void reopen(Universe) {
        LeaseMgrFactory::destroy();
        LeaseMgrFactory::create(validCqlConnectionString());
        lmptr_ = &(LeaseMgrFactory::instance());
    }

    // This is the CQL implementation for GenericLeaseMgrTest::testGetExpiredLeases4().
    // The GenericLeaseMgrTest implementation checks for the order of expired
    // leases to be from the most expired to the least expired. Cassandra
    // doesn't support ORDER BY without imposing a EQ / IN restriction on the
    // columns. Because of that, the order check has been excluded.
    void
    testCqlGetExpiredLeases4() {
        // Get the leases to be used for the test.
        vector<Lease4Ptr> leases = createLeases4();
        // Make sure we have at least 6 leases there.
        ASSERT_GE(leases.size(), 6U);

        // Use the same current time for all leases.
        time_t current_time = time(NULL);

        // Add them to the database
        for (size_t i = 0U; i < leases.size(); ++i) {
            // Mark every other lease as expired.
            if (i % 2U == 0U) {
                // Set client last transmission time to the value older than the
                // valid lifetime to make it expired. The expiration time also
                // depends on the lease index, so as we can later check that the
                // leases are ordered by the expiration time.
                leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 10 - i;

            } else {
                // Set current time as cltt for remaining leases. These leases are
                // not expired.
                leases[i]->cltt_ = current_time;
            }
            ASSERT_TRUE(lmptr_->addLease(leases[i]));
        }

        // Retrieve at most 1000 expired leases.
        Lease4Collection expired_leases;
        ASSERT_NO_THROW(lmptr_->getExpiredLeases4(expired_leases, 1000));
        // Leases with even indexes should be returned as expired.
        ASSERT_EQ(static_cast<size_t>(leases.size() / 2U), expired_leases.size());

        // Update current time for the next test.
        current_time = time(NULL);
        // Also, remove expired leases collected during the previous test.
        expired_leases.clear();

        // This time let's reverse the expiration time and see if they will be returned
        // in the correct order.
        for (size_t i = 0U; i < leases.size(); ++i) {
            // Update the time of expired leases with even indexes.
            if (i % 2U == 0U) {
                leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 1000 + i;
            } else {
                // Make sure remaining leases remain unexpired.
                leases[i]->cltt_ = current_time + 100;
            }
            ASSERT_NO_THROW(lmptr_->updateLease4(leases[i]));
        }

        // Retrieve expired leases again. The limit of 0 means return all expired
        // leases.
        ASSERT_NO_THROW(lmptr_->getExpiredLeases4(expired_leases, 0));
        // The same leases should be returned.
        ASSERT_EQ(static_cast<size_t>(leases.size() / 2U), expired_leases.size());

        // Remember expired leases returned.
        std::vector<Lease4Ptr> saved_expired_leases = expired_leases;

        // Remove expired leases again.
        expired_leases.clear();

        // Limit the number of leases to be returned to 2.
        ASSERT_NO_THROW(lmptr_->getExpiredLeases4(expired_leases, 2));

        // Make sure we have exactly 2 leases returned.
        ASSERT_EQ(2U, expired_leases.size());

        // Mark every other expired lease as reclaimed.
        for (size_t i = 0U; i < saved_expired_leases.size(); ++i) {
            if (i % 2U != 0U) {
                saved_expired_leases[i]->state_ = Lease::STATE_EXPIRED_RECLAIMED;
            }
            ASSERT_NO_THROW(lmptr_->updateLease4(saved_expired_leases[i]));
        }

        expired_leases.clear();

        // This the returned leases should exclude reclaimed ones. So the number
        // of returned leases should be roughly half of the expired leases.
        ASSERT_NO_THROW(lmptr_->getExpiredLeases4(expired_leases, 0U));
        ASSERT_EQ(static_cast<size_t>(saved_expired_leases.size() / 2U),
                  expired_leases.size());

        // Make sure that returned leases are those that are not reclaimed, i.e.
        // those that have even index.
        for (Lease4Collection::iterator lease = expired_leases.begin();
             lease != expired_leases.end(); ++lease) {
            int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
            EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_);
        }
    }

    // This is the CQL implementation for GenericLeaseMgrTest::testGetExpiredLeases4().
    // The GenericLeaseMgrTest implementation checks for the order of expired
    // leases to be from the most expired to the least expired. Cassandra
    // doesn't support ORDER BY without imposing a EQ / IN restriction on the
    // columns. Because of that, the order check has been excluded.
    void
    testCqlGetExpiredLeases6() {
        // Get the leases to be used for the test.
        vector<Lease6Ptr> leases = createLeases6();
        // Make sure we have at least 6 leases there.
        ASSERT_GE(leases.size(), 6U);

        // Use the same current time for all leases.
        time_t current_time = time(NULL);

        // Add them to the database
        for (size_t i = 0U; i < leases.size(); ++i) {
            // Mark every other lease as expired.
            if (i % 2U == 0U) {
                // Set client last transmission time to the value older than the
                // valid lifetime to make it expired. The expiration time also
                // depends on the lease index, so as we can later check that the
                // leases are ordered by the expiration time.
                leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 10 - i;

            } else {
                // Set current time as cltt for remaining leases. These leases are
                // not expired.
                leases[i]->cltt_ = current_time;
            }
            ASSERT_TRUE(lmptr_->addLease(leases[i]));
        }

        // Retrieve at most 1000 expired leases.
        Lease6Collection expired_leases;
        ASSERT_NO_THROW(lmptr_->getExpiredLeases6(expired_leases, 1000));
        // Leases with even indexes should be returned as expired.
        ASSERT_EQ(static_cast<size_t>(leases.size() / 2U), expired_leases.size());

        // Update current time for the next test.
        current_time = time(NULL);
        // Also, remove expired leases collected during the previous test.
        expired_leases.clear();

        // This time let's reverse the expiration time and see if they will be returned
        // in the correct order.
        for (size_t i = 0U; i < leases.size(); ++i) {
            // Update the time of expired leases with even indexes.
            if (i % 2U == 0U) {
                leases[i]->cltt_ = current_time - leases[i]->valid_lft_ - 1000 + i;

            } else {
                // Make sure remaining leases remain unexpired.
                leases[i]->cltt_ = current_time + 100;
            }
            ASSERT_NO_THROW(lmptr_->updateLease6(leases[i]));
        }

        // Retrieve expired leases again. The limit of 0 means return all expired
        // leases.
        ASSERT_NO_THROW(lmptr_->getExpiredLeases6(expired_leases, 0));
        // The same leases should be returned.
        ASSERT_EQ(static_cast<size_t>(leases.size() / 2U), expired_leases.size());

        // Remember expired leases returned.
        std::vector<Lease6Ptr> saved_expired_leases = expired_leases;

        // Remove expired leases again.
        expired_leases.clear();

        // Limit the number of leases to be returned to 2.
        ASSERT_NO_THROW(lmptr_->getExpiredLeases6(expired_leases, 2));

        // Make sure we have exactly 2 leases returned.
        ASSERT_EQ(2U, expired_leases.size());

        // Mark every other expired lease as reclaimed.
        for (size_t i = 0U; i < saved_expired_leases.size(); ++i) {
            if (i % 2U != 0U) {
                saved_expired_leases[i]->state_ = Lease::STATE_EXPIRED_RECLAIMED;
            }
            ASSERT_NO_THROW(lmptr_->updateLease6(saved_expired_leases[i]));
        }

        expired_leases.clear();

        // This the returned leases should exclude reclaimed ones. So the number
        // of returned leases should be roughly half of the expired leases.
        ASSERT_NO_THROW(lmptr_->getExpiredLeases6(expired_leases, 0));

        // Make sure that returned leases are those that are not reclaimed, i.e.
        // those that have even index.
        for (Lease6Collection::iterator lease = expired_leases.begin();
             lease != expired_leases.end(); ++lease) {
            int index = static_cast<int>(std::distance(expired_leases.begin(), lease));
            EXPECT_EQ(saved_expired_leases[2 * index]->addr_, (*lease)->addr_);
        }
    }
};

/// @brief Check that database can be opened
///
/// This test checks if the CqlLeaseMgr can be instantiated. This happens
/// only if the database can be opened. Note that this is not part of the
/// CqlLeaseMgr test fixure set. This test checks that the database can be
/// opened: the fixtures assume that and check basic operations.
/// Unlike other backend implementations, this one doesn't check for lacking
/// parameters. In that scenario, Cassandra defaults to configured parameters.
TEST(CqlOpenTest, OpenDatabase) {

    // Schema needs to be created for the test to work.
    destroyCqlSchema(false, true);
    createCqlSchema(false, true);

    // Check that lease manager open the database opens correctly and tidy up.
    // If it fails, print the error message.
    try {
        LeaseMgrFactory::create(validCqlConnectionString());
        EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
        LeaseMgrFactory::destroy();
    } catch (const isc::Exception& ex) {
        FAIL() << "*** ERROR: unable to open database, reason:\n"
               << "    " << ex.what() << "\n"
               << "*** The test environment is broken and must be fixed\n"
               << "*** before the CQL tests will run correctly.\n";
    }

    // Check that lease manager open the database opens correctly with a longer
    // timeout. If it fails, print the error message.
    try {
        string connection_string = validCqlConnectionString() + string(" ") +
                                   string(VALID_TIMEOUT);
        LeaseMgrFactory::create(connection_string);
        EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
        LeaseMgrFactory::destroy();
    } catch (const isc::Exception& ex) {
        FAIL() << "*** ERROR: unable to open database, reason:\n"
               << "    " << ex.what() << "\n"
               << "*** The test environment is broken and must be fixed\n"
               << "*** before the CQL tests will run correctly.\n";
    }

    // Check that attempting to get an instance of the lease manager when
    // none is set throws an exception.
    EXPECT_THROW(LeaseMgrFactory::instance(), NoLeaseManager);

    // Check that wrong specification of backend throws an exception.
    // (This is really a check on LeaseMgrFactory, but is convenient to
    // perform here.)
    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
        NULL, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
        InvalidParameter);

    EXPECT_THROW(LeaseMgrFactory::create(connectionString(
        INVALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
        InvalidType);

    // Tidy up after the test
    destroyCqlSchema(false, true);
}

/// @brief Check the getType() method
///
/// getType() returns a string giving the type of the backend, which should
/// always be "cql".
TEST_F(CqlLeaseMgrTest, getType) {
    EXPECT_EQ(std::string("cql"), lmptr_->getType());
}

/// @brief Check conversion functions
///
/// The server works using cltt and valid_filetime. In the database, the
/// information is stored as expire_time and valid-lifetime, which are
/// related by
///
/// expire_time = cltt + valid_lifetime
///
/// This test checks that the conversion is correct.
TEST_F(CqlLeaseMgrTest, checkTimeConversion) {
    const time_t cltt = time(NULL);
    const uint32_t valid_lft = 86400;       // 1 day
    uint64_t cql_expire;

    // Convert to the database time
    CqlExchange::convertToDatabaseTime(cltt, valid_lft, cql_expire);

    // Convert back
    time_t converted_cltt = 0;
    CqlExchange::convertFromDatabaseTime(cql_expire, valid_lft, converted_cltt);
    EXPECT_EQ(cltt, converted_cltt);
}

/// @brief Check getName() returns correct keyspace name.
TEST_F(CqlLeaseMgrTest, getName) {
    EXPECT_EQ(std::string("keatest"), lmptr_->getName());
}

/// @brief Check that getVersion() returns the expected version
TEST_F(CqlLeaseMgrTest, checkVersion) {
    // Check version
    pair<uint32_t, uint32_t> version;
    ASSERT_NO_THROW(version = lmptr_->getVersion());
    EXPECT_EQ(CQL_SCHEMA_VERSION_MAJOR, version.first);
    EXPECT_EQ(CQL_SCHEMA_VERSION_MINOR, version.second);
}

////////////////////////////////////////////////////////////////////////////////
/// LEASE4 /////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4 (by address) and deleteLease (with an
/// IPv4 address) works.
TEST_F(CqlLeaseMgrTest, basicLease4) {
    testBasicLease4();
}

/// @brief Check that Lease4 code safely handles invalid dates.
TEST_F(CqlLeaseMgrTest, maxDate4) {
    testMaxDate4();
}

/// @brief Lease4 update tests
///
/// Checks that we are able to update a lease in the database.
TEST_F(CqlLeaseMgrTest, updateLease4) {
    testUpdateLease4();
}

/// @brief Check GetLease4 methods - access by Hardware Address
TEST_F(CqlLeaseMgrTest, getLease4HWAddr1) {
    testGetLease4HWAddr1();
}

/// @brief Check GetLease4 methods - access by Hardware Address
TEST_F(CqlLeaseMgrTest, getLease4HWAddr2) {
    testGetLease4HWAddr2();
}

// @brief Get lease4 by hardware address (2)
//
// Check that the system can cope with getting a hardware address of
// any size.
TEST_F(CqlLeaseMgrTest, getLease4HWAddrSize) {
    testGetLease4HWAddrSize();
}

/// @brief Check GetLease4 methods - access by Hardware Address & Subnet ID
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of hardware address and subnet ID
TEST_F(CqlLeaseMgrTest, getLease4HwaddrSubnetId) {
    testGetLease4HWAddrSubnetId();
}

// @brief Get lease4 by hardware address and subnet ID (2)
//
// Check that the system can cope with getting a hardware address of
// any size.
TEST_F(CqlLeaseMgrTest, getLease4HWAddrSubnetIdSize) {
    testGetLease4HWAddrSubnetIdSize();
}

// This test was derived from memfile.
TEST_F(CqlLeaseMgrTest, getLease4ClientId) {
    testGetLease4ClientId();
}

/// @brief Check GetLease4 methods - access by Client ID
///
/// Adds leases to the database and checks that they can be accessed via
/// the Client ID.
TEST_F(CqlLeaseMgrTest, getLease4ClientId2) {
    testGetLease4ClientId2();
}

// @brief Get Lease4 by client ID (2)
//
// Check that the system can cope with a client ID of any size.
TEST_F(CqlLeaseMgrTest, getLease4ClientIdSize) {
    testGetLease4ClientIdSize();
}

/// @brief Check GetLease4 methods - access by Client ID & Subnet ID
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of client and subnet IDs.
TEST_F(CqlLeaseMgrTest, getLease4ClientIdSubnetId) {
    testGetLease4ClientIdSubnetId();
}

/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr, subnet_id),
/// updateLease4() and deleteLease (IPv4 address) can handle NULL client-id.
/// (client-id is optional and may not be present)
TEST_F(CqlLeaseMgrTest, lease4NullClientId) {
    testLease4NullClientId();
}

/// @brief Verify that too long hostname for Lease4 is not accepted.
///
/// Checks that the it is not possible to create a lease when the hostname
/// length exceeds 255 characters.
TEST_F(CqlLeaseMgrTest, lease4InvalidHostname) {
    testLease4InvalidHostname();
}

////////////////////////////////////////////////////////////////////////////////
/// LEASE6 /////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

// Test checks whether simple add, get and delete operations are possible
// on Lease6
TEST_F(CqlLeaseMgrTest, testAddGetDelete6) {
    testAddGetDelete6(false);
}

/// @brief Basic Lease6 Checks
///
/// Checks that the addLease, getLease6 (by address) and deleteLease (with an
/// IPv6 address) works.
TEST_F(CqlLeaseMgrTest, basicLease6) {
    testBasicLease6();
}

/// @brief Check that Lease6 code safely handles invalid dates.
TEST_F(CqlLeaseMgrTest, maxDate6) {
    testMaxDate6();
}

/// @brief Verify that too long hostname for Lease6 is not accepted.
///
/// Checks that the it is not possible to create a lease when the hostname
/// length exceeds 255 characters.
TEST_F(CqlLeaseMgrTest, lease6InvalidHostname) {
    testLease6InvalidHostname();
}

/// @brief Check GetLease6 methods - access by DUID/IAID
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of DUID and IAID.
TEST_F(CqlLeaseMgrTest, getLeases6DuidIaid) {
    testGetLeases6DuidIaid();
}

// Check that the system can cope with a DUID of allowed size.
TEST_F(CqlLeaseMgrTest, getLeases6DuidSize) {
    testGetLeases6DuidSize();
}

/// @brief Check that getLease6 methods discriminate by lease type.
///
/// Adds six leases, two per lease type all with the same duid and iad but
/// with alternating subnet_ids.
/// It then verifies that all of getLeases6() method variants correctly
/// discriminate between the leases based on lease type alone.
TEST_F(CqlLeaseMgrTest, lease6LeaseTypeCheck) {
    testLease6LeaseTypeCheck();
}

/// @brief Check GetLease6 methods - access by DUID/IAID/SubnetID
///
/// Adds leases to the database and checks that they can be accessed via
/// a combination of DIUID and IAID.
TEST_F(CqlLeaseMgrTest, getLease6DuidIaidSubnetId) {
    testGetLease6DuidIaidSubnetId();
}

// Test checks that getLease6() works with different DUID sizes
TEST_F(CqlLeaseMgrTest, getLease6DuidIaidSubnetIdSize) {
    testGetLease6DuidIaidSubnetIdSize();
}

/// @brief Lease6 update tests
///
/// Checks that we are able to update a lease in the database.
TEST_F(CqlLeaseMgrTest, updateLease6) {
    testUpdateLease6();
}

/// @brief DHCPv4 Lease recreation tests
///
/// Checks that the lease can be created, deleted and recreated with
/// different parameters. It also checks that the re-created lease is
/// correctly stored in the lease database.
TEST_F(CqlLeaseMgrTest, testRecreateLease4) {
    testRecreateLease4();
}

/// @brief DHCPv6 Lease recreation tests
///
/// Checks that the lease can be created, deleted and recreated with
/// different parameters. It also checks that the re-created lease is
/// correctly stored in the lease database.
TEST_F(CqlLeaseMgrTest, testRecreateLease6) {
    testRecreateLease6();
}

/// @brief Checks that null DUID is not allowed.
TEST_F(CqlLeaseMgrTest, nullDuid) {
    testNullDuid();
}

/// @brief Tests whether memfile can store and retrieve hardware addresses
TEST_F(CqlLeaseMgrTest, testLease6Mac) {
    testLease6MAC();
}

/// @brief Tests whether memfile can store and retrieve hardware addresses
TEST_F(CqlLeaseMgrTest, testLease6HWTypeAndSource) {
    testLease6HWTypeAndSource();
}

/// @brief Check that the expired DHCPv4 leases can be retrieved.
///
/// This test adds a number of leases to the lease database and marks
/// some of them as expired. Then it queries for expired leases and checks
/// whether only expired leases are returned, and that they are returned in
/// the order from most to least expired. It also checks that the lease
/// which is marked as 'reclaimed' is not returned.
TEST_F(CqlLeaseMgrTest, getExpiredLeases4) {
    testCqlGetExpiredLeases4();
}

/// @brief Check that the expired DHCPv6 leases can be retrieved.
///
/// This test adds a number of leases to the lease database and marks
/// some of them as expired. Then it queries for expired leases and checks
/// whether only expired leases are returned, and that they are returned in
/// the order from most to least expired. It also checks that the lease
/// which is marked as 'reclaimed' is not returned.
TEST_F(CqlLeaseMgrTest, getExpiredLeases6) {
    testCqlGetExpiredLeases6();
}

/// @brief Check that expired reclaimed DHCPv6 leases are removed.
TEST_F(CqlLeaseMgrTest, deleteExpiredReclaimedLeases6) {
    testDeleteExpiredReclaimedLeases6();
}

/// @brief Check that expired reclaimed DHCPv4 leases are removed.
TEST_F(CqlLeaseMgrTest, deleteExpiredReclaimedLeases4) {
    testDeleteExpiredReclaimedLeases4();
}

}; // Of anonymous namespace