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
// Copyright (C) 2023-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include <config.h>

#include <asiolink/io_address.h>
#include <cc/data.h>
#include <dhcpsrv/testutils/generic_lease_extended_info_unittest.h>
#include <pgsql/testutils/pgsql_schema.h>
#include <pgsql_lease_mgr.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.

using namespace isc;
using namespace isc::asiolink;
using namespace isc::data;
using namespace isc::db;
using namespace isc::db::test;
using namespace isc::dhcp;
using namespace isc::test;
using namespace isc::util;
using namespace std;

namespace {

/// @brief A derivation of the lease manager exposing protected methods.
class NakedPgSqlLeaseMgr : public PgSqlLeaseMgr {
public:
    /// @brief Constructor.
    ///
    /// Creates an instance of the lease manager.
    ///
    /// @param parameters Parameter map.
    NakedPgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters)
        : PgSqlLeaseMgr(parameters) {
    }

    /// @brief Destructor.
    virtual ~NakedPgSqlLeaseMgr() {
    }

    /// @brief Exposes protected methods.
    using PgSqlLeaseMgr::deleteExtendedInfo6;
    using PgSqlLeaseMgr::addRelayId6;
    using PgSqlLeaseMgr::addRemoteId6;

    /// @brief Return valid connection string.
    static string validConnectionString() {
        return (validPgSQLConnectionString());
    }

    /// @brief Create the database schema.
    static void createSchema() {
        createPgSQLSchema();
    }

    /// @brief Destroy the database schema.
    static void destroySchema() {
        destroyPgSQLSchema();
    }

    /// @brief Initializer.
    PgSqlLeaseMgrInit init_;
};

/// @brief Test fixture class for extended info tests.
class PgSqlExtendedInfoTest : public isc::dhcp::test::GenericExtendedInfoTest<NakedPgSqlLeaseMgr> {
    /// @brief Initializer.
    PgSqlLeaseMgrInit init_;
};

/// @brief Verifies that the lease manager can start.
TEST_F(PgSqlExtendedInfoTest, startWithoutExtendedTables) {<--- syntax error
    start(false);
}

/// @brief Verifies that the lease manager can start with MT.
TEST_F(PgSqlExtendedInfoTest, startWithoutExtendedTablesMultiThreading) {
    MultiThreadingTest mt(true);
    start(false);
}

/// @brief Verifies that the lease manager can start with tables.
TEST_F(PgSqlExtendedInfoTest, startWithExtendedTables) {
    start(true);
}

/// @brief Verifies that the lease manager can start with tables and MT.
TEST_F(PgSqlExtendedInfoTest, startWithExtendedTablesMultiThreading) {
    MultiThreadingTest mt(true);
    start(true);
}

TEST_F(PgSqlExtendedInfoTest, initLease4) {
    testInitLease4();
}

TEST_F(PgSqlExtendedInfoTest, initLease4MultiThreading) {
    MultiThreadingTest mt(true);
    testInitLease4();
}

TEST_F(PgSqlExtendedInfoTest, getLeases4ByRelayId) {
    testGetLeases4ByRelayId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases4ByRelayIdMultiThreading) {
    MultiThreadingTest mt(true);
    testGetLeases4ByRelayId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases4ByRemoteId) {
    testGetLeases4ByRemoteId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases4ByRemoteIdMultiThreading) {
    MultiThreadingTest mt(true);
    testGetLeases4ByRemoteId();
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4None) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_NONE,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4Fix) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4Strict) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_STRICT,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4Pedantic) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_PEDANTIC,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4_10) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             LeasePageSize(10));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4_5) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             LeasePageSize(5));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4_2) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             LeasePageSize(2));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo4_1) {
    testUpgradeExtendedInfo4(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             LeasePageSize(1));
}

TEST_F(PgSqlExtendedInfoTest, initLease6) {
    testInitLease6();
}

TEST_F(PgSqlExtendedInfoTest, initLease6MultiThreading) {
    MultiThreadingTest mt(true);
    testInitLease6();
}

TEST_F(PgSqlExtendedInfoTest, enableTables) {
    testEnableTables();
}

TEST_F(PgSqlExtendedInfoTest, enableTablesMultiThreading) {
    MultiThreadingTest mt(true);
    testEnableTables();
}

TEST_F(PgSqlExtendedInfoTest, deleteCascade) {
    testDeleteCascade();
}

TEST_F(PgSqlExtendedInfoTest, deleteCascadeMultiThreading) {
    MultiThreadingTest mt(true);
    testDeleteCascade();
}

TEST_F(PgSqlExtendedInfoTest, getLeases6ByRelayId) {
    testGetLeases6ByRelayId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases6ByRelayIdMultiThreading) {
    MultiThreadingTest mt(true);
    testGetLeases6ByRelayId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases6ByRemoteId) {
    testGetLeases6ByRemoteId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases6ByRemoteIdMultiThreading) {
    MultiThreadingTest mt(true);
    testGetLeases6ByRemoteId();
}

TEST_F(PgSqlExtendedInfoTest, getLeases6ByLink) {
    testGetLeases6ByLink();
}

TEST_F(PgSqlExtendedInfoTest, getLeases6ByLinkMultiThreading) {
    MultiThreadingTest mt(true);
    testGetLeases6ByLink();
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo6NoCheckDisabled) {
    testUpgradeExtendedInfo6(CfgConsistency::EXTENDED_INFO_CHECK_NONE,
                             false,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo6NoCheckEnabled) {
    testUpgradeExtendedInfo6(CfgConsistency::EXTENDED_INFO_CHECK_NONE,
                             true,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo6FixkDisabled) {
    testUpgradeExtendedInfo6(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             false,
                             LeasePageSize(100));
}

TEST_F(PgSqlExtendedInfoTest, upgradeExtendedInfo6FixEnabled) {
    testUpgradeExtendedInfo6(CfgConsistency::EXTENDED_INFO_CHECK_FIX,
                             true,
                             LeasePageSize(100));
}

}  // namespace