Skip to content

Commit

Permalink
[#89,!22] Use run_statement function to validate cb mysql tables.
Browse files Browse the repository at this point in the history
  • Loading branch information
msiodelski committed Sep 18, 2018
1 parent 70bab5e commit 20bc3ce
Showing 1 changed file with 59 additions and 116 deletions.
175 changes: 59 additions & 116 deletions src/bin/admin/tests/mysql_tests.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -470,177 +470,120 @@ EOF
assert_eq 0 $ERRCODE "logs table is missing or broken. (expected status code %d, returned %d)"

# table: modification (upgrade 6.0 -> 7.0)
qry="select id, modification_type from modification";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "modification table is missing or broken. (expected status code %d, returned %d)"
qry="select id, modification_type from modification"
run_statement "modification" "$qry"

# table: modification table should have 3 entries (upgrade 6.0 -> 7.0)
qry="select count(*) from modification";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 3 "$count" "modification table does not contain correct number of entries. (expected count %d, returned %d)"
qry="select count(*) from modification"
run_statement "modification count" "$qry" 3

# table: dhcp4_server
qry="select id, tag, description, modification_ts from dhcp4_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_server table missing or broken (expected status code %d, returned %d)";
qry="select id, tag, description, modification_ts from dhcp4_server"
run_statement "dhcp4_server" "$qry"

# table: dhcp4_audit
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp4_audit";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_audit table missing or broken (expected status code %d, returned %d)";
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp4_audit"
run_statement "dhcp4_audit" "$qry"

# table: dhcp4_global_parameter
qry="select id, name, value, modification_ts from dhcp4_global_parameter";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_global_parameter table missing or broken (expected status code %d, returned %d)";
qry="select id, name, value, modification_ts from dhcp4_global_parameter"
run_statement "dhcp4_global_parameter" "$qry"

# table: dhcp4_global_parameter_server
qry="select parameter_id, server_id, modification_ts from dhcp4_global_parameter_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_global_parameter_server table missing or broken (expected status code %d, returned %d)";
qry="select parameter_id, server_id, modification_ts from dhcp4_global_parameter_server"
run_statement "dhcp4_global_parameter_server" "$qry"

# table: dhcp4_option_def
qry="select id, code, space, modification_ts, array, encapsulate, record_types, user_context from dhcp4_option_def";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_option_def table missing or broken (expected status code %d, returned %d)";
qry="select id, code, space, modification_ts, array, encapsulate, record_types, user_context from dhcp4_option_def"
run_statement "dhcp4_option_def" "$qry"

# table: dhcp4_option_def_server
qry="select option_def_id, server_id, modification_ts from dhcp4_option_def_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_option_def_server table missing or broken (expected status code %d, returned %d)";
qry="select option_def_id, server_id, modification_ts from dhcp4_option_def_server"
run_statement "dhcp4_option_def_server" "$qry"

# table: dhcp4_shared_network
qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, user_context, valid_lifetime from dhcp4_shared_network";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_shared_network table missing or broken (expected status code %d, returned %d)";
qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, user_context, valid_lifetime from dhcp4_shared_network"
run_statement "dhcp4_shared_network" "$qry"

# table: dhcp4_shared_network_server
qry="select shared_network_id, server_id, modification_ts from dhcp4_shared_network_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_shared_network_server table missing or broken (expected status code %d, returned %d)";
qry="select shared_network_id, server_id, modification_ts from dhcp4_shared_network_server"
run_statement "dhcp4_shared_network_server" "$qry"

# table: dhcp4_subnet
qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime from dhcp4_subnet";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_subnet table missing or broken (expected status code %d, returned %d)";
qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime from dhcp4_subnet"
run_statement "dhcp4_subnet" "$qry"

# table: dhcp4_pool
qry="select id, start_address, end_address, subnet_id, modification_ts from dhcp4_pool";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_pool table missing or broken (expected status code %d, returned %d)";
qry="select id, start_address, end_address, subnet_id, modification_ts from dhcp4_pool"
run_statement "dhcp4_pool" "$qry"

# table: dhcp4_subnet_server
qry="select subnet_id, server_id, modification_ts from dhcp4_subnet_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_subnet_server table missing or broken (expected status code %d, returned %d)";
qry="select subnet_id, server_id, modification_ts from dhcp4_subnet_server"
run_statement "dhcp4_subnet_server" "$qry"

# table: dhcp4_options (should include three new columns)
qry="select shared_network_name, pool_id, modification_ts from dhcp4_options";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_options table missing or broken (expected status code %d, returned %d)";
qry="select shared_network_name, pool_id, modification_ts from dhcp4_options"
run_statement "dhcp4_options" "$qry"

# table: dhcp4_options_server
qry="select option_id, server_id, modification_ts from dhcp4_options_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp4_options_server table missing or broken (expected status code %d, returned %d)";
qry="select option_id, server_id, modification_ts from dhcp4_options_server"
run_statement "dhcp4_options_server" "$qry"

# table: dhcp6_server
qry="select id, tag, description, modification_ts from dhcp6_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_server table missing or broken (expected status code %d, returned %d)";
qry="select id, tag, description, modification_ts from dhcp6_server"
run_statement "dhcp6_server" "$qry"

# table: dhcp6_audit
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp6_audit";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_audit table missing or broken (expected status code %d, returned %d)";
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp6_audit"
run_statement "dhcp6_audit" "$qry"

# table: dhcp6_global_parameter
qry="select id, name, value, modification_ts from dhcp6_global_parameter";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_global_parameter table missing or broken (expected status code %d, returned %d)";
qry="select id, name, value, modification_ts from dhcp6_global_parameter"
run_statement "dhcp6_global_parameter" "$qry"

# table: dhcp6_global_parameter_server
qry="select parameter_id, server_id, modification_ts from dhcp6_global_parameter_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_global_parameter_server table missing or broken (expected status code %d, returned %d)";
qry="select parameter_id, server_id, modification_ts from dhcp6_global_parameter_server"
run_statement "dhcp6_global_parameter_server" "$qry"

# table: dhcp6_option_def
qry="select id, code, space, modification_ts, array, encapsulate, record_types, user_context from dhcp6_option_def";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_option_def table missing or broken (expected status code %d, returned %d)";
qry="select id, code, space, modification_ts, array, encapsulate, record_types, user_context from dhcp6_option_def"
run_statement "dhcp6_option_def" "$qry"

# table: dhcp6_option_def_server
qry="select option_def_id, server_id, modification_ts from dhcp6_option_def_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_option_def_server table missing or broken (expected status code %d, returned %d)";
qry="select option_def_id, server_id, modification_ts from dhcp6_option_def_server"
run_statement "dhcp6_option_def_server" "$qry"

# table: dhcp6_shared_network
qry="select id, name, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, user_context, valid_lifetime from dhcp6_shared_network";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_shared_network table missing or broken (expected status code %d, returned %d)";
qry="select id, name, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, user_context, valid_lifetime from dhcp6_shared_network"
run_statement "dhcp6_shared_network" "$qry"

# table: dhcp6_shared_network_server
qry="select shared_network_id, server_id, modification_ts from dhcp6_shared_network_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_shared_network_server table missing or broken (expected status code %d, returned %d)";
qry="select shared_network_id, server_id, modification_ts from dhcp6_shared_network_server"
run_statement "dhcp6_shared_network" "$qry"

# table: dhcp6_subnet
qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, shared_network_name, subnet_id, user_context, valid_lifetime from dhcp6_subnet";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_subnet table missing or broken (expected status code %d, returned %d)";
qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, shared_network_name, subnet_id, user_context, valid_lifetime from dhcp6_subnet"
run_statement "dhcp6_subnet" "$qry"

# table: dhcp6_subnet_server
qry="select subnet_id, server_id, modification_ts from dhcp6_subnet_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_subnet_server table missing or broken (expected status code %d, returned %d)";
qry="select subnet_id, server_id, modification_ts from dhcp6_subnet_server"
run_statement "dhcp6_subnet_server" "$qry"

# table: dhcp6_pd_pool
qry="select id, prefix_length, delegated_prefix_length, dhcp6_subnet_id, modification_ts from dhcp6_pd_pool";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_pd_pool table missing or broken (expected status code %d, returned %d)";
qry="select id, prefix_length, delegated_prefix_length, dhcp6_subnet_id, modification_ts from dhcp6_pd_pool"
run_statement "dhcp6_pd_pool" "$qry"

# table: dhcp6_pool
qry="select id, start_address, end_address, dhcp6_subnet_id, modification_ts from dhcp6_pool";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_pool table missing or broken (expected status code %d, returned %d)";
qry="select id, start_address, end_address, dhcp6_subnet_id, modification_ts from dhcp6_pool"
run_statement "dhcp6_pool" "$qry"

# table: dhcp6_options (should include four new columns)
qry="select shared_network_name, pool_id, pd_pool_id, modification_ts from dhcp6_options";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_options table missing or broken (expected status code %d, returned %d)";
qry="select shared_network_name, pool_id, pd_pool_id, modification_ts from dhcp6_options"
run_statement "dhcp6_options" "$qry"

# table: dhcp6_options_server
qry="select option_id, server_id, modification_ts from dhcp6_options_server";
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "dhcp6_options_server table missing or broken (expected status code %d, returned %d)";
qry="select option_id, server_id, modification_ts from dhcp6_options_server"
run_statement "dhcp6_options_server" "$qry"

# Verify upgraded schema reports version 7.0
version=$(${keaadmin} lease-version mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
Expand Down

0 comments on commit 20bc3ce

Please sign in to comment.