/memfile_tests.sh
/mysql_tests.sh
/pgsql_tests.sh
+/cql_tests.sh
namespace isc {
namespace dhcp {
+enum ExchangeDataType {
+ EXCHANGE_DATA_TYPE_NONE,
+ EXCHANGE_DATA_TYPE_BOOL,
+ EXCHANGE_DATA_TYPE_INT32,
+ EXCHANGE_DATA_TYPE_INT64,
+ EXCHANGE_DATA_TYPE_TIMESTAMP,
+ EXCHANGE_DATA_TYPE_STRING,
+ EXCHANGE_DATA_TYPE_BYTES
+};
+
+enum ExchangeDataTypeIO {
+ EXCHANGE_DATA_TYPE_IO_IN,
+ EXCHANGE_DATA_TYPE_IO_OUT,
+ EXCHANGE_DATA_TYPE_IO_IN_OUT
+};
+
+struct ExchangeColumnInfo {
+ ExchangeColumnInfo () : column_(NULL), type_io_(EXCHANGE_DATA_TYPE_IO_IN), type_(EXCHANGE_DATA_TYPE_NONE) {};
+ ExchangeColumnInfo (const char *column, ExchangeDataTypeIO type_io, ExchangeDataType type) : column_(column), type_io_(type_io), type_(type) {};
+ const char* column_;
+ ExchangeDataTypeIO type_io_;
+ ExchangeDataType type_;
+};
+
+class SqlExchange {
+public:
+ SqlExchange () {};
+ virtual ~SqlExchange() {};
+ std::vector<ExchangeColumnInfo> parameters_; ///< Column names and types
+};
/// @brief Abstract Lease Manager
///
/// This is an abstract API for lease database backends. It provides unified
hostname_ = getRawColumnValue(r, row, HOSTNAME_COL);
+ uint32_t state;
+ getColumnValue(r, row , STATE_COL, state);
+
HWAddrPtr hwaddr(new HWAddr(hwaddr_buffer_, hwaddr_length_,
HTYPE_ETHER));
- return (Lease4Ptr(new Lease4(addr4_, hwaddr,
+ Lease4Ptr result(new Lease4(addr4_, hwaddr,
client_id_buffer_, client_id_length_,
valid_lifetime_, 0, 0, cltt_,
subnet_id_, fqdn_fwd_, fqdn_rev_,
- hostname_)));
+ hostname_));
+ result->state_ = state;
+ return (result);
} catch (const std::exception& ex) {
isc_throw(DbOperationError,
"Could not convert data to Lease4, reason: "
hostname_ = getRawColumnValue(r, row, HOSTNAME_COL);
+ uint32_t state;
+ getColumnValue(r, row , STATE_COL, state);
+
/// @todo: implement this in #3557.
HWAddrPtr hwaddr;
subnet_id_, fqdn_fwd_, fqdn_rev_,
hostname_, hwaddr, prefix_len_));
result->cltt_ = cltt_;
+ result->state_ = state;
return (result);
} catch (const std::exception& ex) {
isc_throw(DbOperationError,
createCqlSchema(false, true);
// Check that lease manager open the database opens correctly and tidy up.
- // If it fails, print the error message.
+ // If it fails, print the error message.
try {
LeaseMgrFactory::create(validCqlConnectionString());
EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
<< "*** 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);
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);
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
CQL_VALID_TYPE, INVALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD)),
DbOpenError);
+
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
CQL_VALID_TYPE, VALID_NAME, INVALID_HOST, VALID_USER, VALID_PASSWORD)),
DbOpenError);
+
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
CQL_VALID_TYPE, VALID_NAME, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
DbOpenError);
+
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, INVALID_PASSWORD)),
DbOpenError);
+ // Check for invalid timeouts
+ EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+ CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_1)),
+ DbInvalidTimeout);
+ EXPECT_THROW(LeaseMgrFactory::create(connectionString(
+ CQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_2)),
+ DbInvalidTimeout);
+
// Check for missing parameters
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
CQL_VALID_TYPE, NULL, VALID_HOST, INVALID_USER, VALID_PASSWORD)),
/// Closes the database and re-open it. Anything committed should be
/// visible.
///
- /// Parameter is ignored for Postgres abckend as the v4 and v6 leases share
+ /// Parameter is ignored for Postgres backend as the v4 and v6 leases share
/// the same database.
void reopen(Universe) {
LeaseMgrFactory::destroy();
createPgSQLSchema(true);
// Check that lease manager open the database opens correctly and tidy up.
- // If it fails, print the error message.
+ // If it fails, print the error message.
try {
LeaseMgrFactory::create(validPgSQLConnectionString());
EXPECT_NO_THROW((void) LeaseMgrFactory::instance());
FAIL() << "*** ERROR: unable to open database, reason:\n"
<< " " << ex.what() << "\n"
<< "*** The test environment is broken and must be fixed\n"
- << "*** before the MySQL tests will run correctly.\n";
+ << "*** before the PostgreSQL tests will run correctly.\n";
}
// Check that attempting to get an instance of the lease manager when