Skip to content

Commit 20bc3ce

Browse files
committed
[#89,!22] Use run_statement function to validate cb mysql tables.
1 parent 70bab5e commit 20bc3ce

File tree

1 file changed

+59
-116
lines changed

1 file changed

+59
-116
lines changed

src/bin/admin/tests/mysql_tests.sh.in

Lines changed: 59 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -470,177 +470,120 @@ EOF
470470
assert_eq 0 $ERRCODE "logs table is missing or broken. (expected status code %d, returned %d)"
471471

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

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

484480
# table: dhcp4_server
485-
qry="select id, tag, description, modification_ts from dhcp4_server";
486-
count=`mysql_execute "${qry}"`
487-
ERRCODE=$?
488-
assert_eq 0 $ERRCODE "dhcp4_server table missing or broken (expected status code %d, returned %d)";
481+
qry="select id, tag, description, modification_ts from dhcp4_server"
482+
run_statement "dhcp4_server" "$qry"
489483

490484
# table: dhcp4_audit
491-
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp4_audit";
492-
count=`mysql_execute "${qry}"`
493-
ERRCODE=$?
494-
assert_eq 0 $ERRCODE "dhcp4_audit table missing or broken (expected status code %d, returned %d)";
485+
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp4_audit"
486+
run_statement "dhcp4_audit" "$qry"
495487

496488
# table: dhcp4_global_parameter
497-
qry="select id, name, value, modification_ts from dhcp4_global_parameter";
498-
count=`mysql_execute "${qry}"`
499-
ERRCODE=$?
500-
assert_eq 0 $ERRCODE "dhcp4_global_parameter table missing or broken (expected status code %d, returned %d)";
489+
qry="select id, name, value, modification_ts from dhcp4_global_parameter"
490+
run_statement "dhcp4_global_parameter" "$qry"
501491

502492
# table: dhcp4_global_parameter_server
503-
qry="select parameter_id, server_id, modification_ts from dhcp4_global_parameter_server";
504-
count=`mysql_execute "${qry}"`
505-
ERRCODE=$?
506-
assert_eq 0 $ERRCODE "dhcp4_global_parameter_server table missing or broken (expected status code %d, returned %d)";
493+
qry="select parameter_id, server_id, modification_ts from dhcp4_global_parameter_server"
494+
run_statement "dhcp4_global_parameter_server" "$qry"
507495

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

514500
# table: dhcp4_option_def_server
515-
qry="select option_def_id, server_id, modification_ts from dhcp4_option_def_server";
516-
count=`mysql_execute "${qry}"`
517-
ERRCODE=$?
518-
assert_eq 0 $ERRCODE "dhcp4_option_def_server table missing or broken (expected status code %d, returned %d)";
501+
qry="select option_def_id, server_id, modification_ts from dhcp4_option_def_server"
502+
run_statement "dhcp4_option_def_server" "$qry"
519503

520504
# table: dhcp4_shared_network
521-
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";
522-
count=`mysql_execute "${qry}"`
523-
ERRCODE=$?
524-
assert_eq 0 $ERRCODE "dhcp4_shared_network table missing or broken (expected status code %d, returned %d)";
505+
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"
506+
run_statement "dhcp4_shared_network" "$qry"
525507

526508
# table: dhcp4_shared_network_server
527-
qry="select shared_network_id, server_id, modification_ts from dhcp4_shared_network_server";
528-
count=`mysql_execute "${qry}"`
529-
ERRCODE=$?
530-
assert_eq 0 $ERRCODE "dhcp4_shared_network_server table missing or broken (expected status code %d, returned %d)";
509+
qry="select shared_network_id, server_id, modification_ts from dhcp4_shared_network_server"
510+
run_statement "dhcp4_shared_network_server" "$qry"
531511

532512
# table: dhcp4_subnet
533-
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";
534-
count=`mysql_execute "${qry}"`
535-
ERRCODE=$?
536-
assert_eq 0 $ERRCODE "dhcp4_subnet table missing or broken (expected status code %d, returned %d)";
513+
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"
514+
run_statement "dhcp4_subnet" "$qry"
537515

538516
# table: dhcp4_pool
539-
qry="select id, start_address, end_address, subnet_id, modification_ts from dhcp4_pool";
540-
count=`mysql_execute "${qry}"`
541-
ERRCODE=$?
542-
assert_eq 0 $ERRCODE "dhcp4_pool table missing or broken (expected status code %d, returned %d)";
517+
qry="select id, start_address, end_address, subnet_id, modification_ts from dhcp4_pool"
518+
run_statement "dhcp4_pool" "$qry"
543519

544520
# table: dhcp4_subnet_server
545-
qry="select subnet_id, server_id, modification_ts from dhcp4_subnet_server";
546-
count=`mysql_execute "${qry}"`
547-
ERRCODE=$?
548-
assert_eq 0 $ERRCODE "dhcp4_subnet_server table missing or broken (expected status code %d, returned %d)";
521+
qry="select subnet_id, server_id, modification_ts from dhcp4_subnet_server"
522+
run_statement "dhcp4_subnet_server" "$qry"
549523

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

556528
# table: dhcp4_options_server
557-
qry="select option_id, server_id, modification_ts from dhcp4_options_server";
558-
count=`mysql_execute "${qry}"`
559-
ERRCODE=$?
560-
assert_eq 0 $ERRCODE "dhcp4_options_server table missing or broken (expected status code %d, returned %d)";
529+
qry="select option_id, server_id, modification_ts from dhcp4_options_server"
530+
run_statement "dhcp4_options_server" "$qry"
531+
561532
# table: dhcp6_server
562-
qry="select id, tag, description, modification_ts from dhcp6_server";
563-
count=`mysql_execute "${qry}"`
564-
ERRCODE=$?
565-
assert_eq 0 $ERRCODE "dhcp6_server table missing or broken (expected status code %d, returned %d)";
533+
qry="select id, tag, description, modification_ts from dhcp6_server"
534+
run_statement "dhcp6_server" "$qry"
566535

567536
# table: dhcp6_audit
568-
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp6_audit";
569-
count=`mysql_execute "${qry}"`
570-
ERRCODE=$?
571-
assert_eq 0 $ERRCODE "dhcp6_audit table missing or broken (expected status code %d, returned %d)";
537+
qry="select id, object_type, object_id, modification_type, modification_ts from dhcp6_audit"
538+
run_statement "dhcp6_audit" "$qry"
572539

573540
# table: dhcp6_global_parameter
574-
qry="select id, name, value, modification_ts from dhcp6_global_parameter";
575-
count=`mysql_execute "${qry}"`
576-
ERRCODE=$?
577-
assert_eq 0 $ERRCODE "dhcp6_global_parameter table missing or broken (expected status code %d, returned %d)";
541+
qry="select id, name, value, modification_ts from dhcp6_global_parameter"
542+
run_statement "dhcp6_global_parameter" "$qry"
578543

579544
# table: dhcp6_global_parameter_server
580-
qry="select parameter_id, server_id, modification_ts from dhcp6_global_parameter_server";
581-
count=`mysql_execute "${qry}"`
582-
ERRCODE=$?
583-
assert_eq 0 $ERRCODE "dhcp6_global_parameter_server table missing or broken (expected status code %d, returned %d)";
545+
qry="select parameter_id, server_id, modification_ts from dhcp6_global_parameter_server"
546+
run_statement "dhcp6_global_parameter_server" "$qry"
584547

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

591552
# table: dhcp6_option_def_server
592-
qry="select option_def_id, server_id, modification_ts from dhcp6_option_def_server";
593-
count=`mysql_execute "${qry}"`
594-
ERRCODE=$?
595-
assert_eq 0 $ERRCODE "dhcp6_option_def_server table missing or broken (expected status code %d, returned %d)";
553+
qry="select option_def_id, server_id, modification_ts from dhcp6_option_def_server"
554+
run_statement "dhcp6_option_def_server" "$qry"
596555

597556
# table: dhcp6_shared_network
598-
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";
599-
count=`mysql_execute "${qry}"`
600-
ERRCODE=$?
601-
assert_eq 0 $ERRCODE "dhcp6_shared_network table missing or broken (expected status code %d, returned %d)";
557+
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"
558+
run_statement "dhcp6_shared_network" "$qry"
602559

603560
# table: dhcp6_shared_network_server
604-
qry="select shared_network_id, server_id, modification_ts from dhcp6_shared_network_server";
605-
count=`mysql_execute "${qry}"`
606-
ERRCODE=$?
607-
assert_eq 0 $ERRCODE "dhcp6_shared_network_server table missing or broken (expected status code %d, returned %d)";
561+
qry="select shared_network_id, server_id, modification_ts from dhcp6_shared_network_server"
562+
run_statement "dhcp6_shared_network" "$qry"
608563

609564
# table: dhcp6_subnet
610-
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";
611-
count=`mysql_execute "${qry}"`
612-
ERRCODE=$?
613-
assert_eq 0 $ERRCODE "dhcp6_subnet table missing or broken (expected status code %d, returned %d)";
565+
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"
566+
run_statement "dhcp6_subnet" "$qry"
614567

615568
# table: dhcp6_subnet_server
616-
qry="select subnet_id, server_id, modification_ts from dhcp6_subnet_server";
617-
count=`mysql_execute "${qry}"`
618-
ERRCODE=$?
619-
assert_eq 0 $ERRCODE "dhcp6_subnet_server table missing or broken (expected status code %d, returned %d)";
569+
qry="select subnet_id, server_id, modification_ts from dhcp6_subnet_server"
570+
run_statement "dhcp6_subnet_server" "$qry"
620571

621572
# table: dhcp6_pd_pool
622-
qry="select id, prefix_length, delegated_prefix_length, dhcp6_subnet_id, modification_ts from dhcp6_pd_pool";
623-
count=`mysql_execute "${qry}"`
624-
ERRCODE=$?
625-
assert_eq 0 $ERRCODE "dhcp6_pd_pool table missing or broken (expected status code %d, returned %d)";
573+
qry="select id, prefix_length, delegated_prefix_length, dhcp6_subnet_id, modification_ts from dhcp6_pd_pool"
574+
run_statement "dhcp6_pd_pool" "$qry"
626575

627576
# table: dhcp6_pool
628-
qry="select id, start_address, end_address, dhcp6_subnet_id, modification_ts from dhcp6_pool";
629-
count=`mysql_execute "${qry}"`
630-
ERRCODE=$?
631-
assert_eq 0 $ERRCODE "dhcp6_pool table missing or broken (expected status code %d, returned %d)";
577+
qry="select id, start_address, end_address, dhcp6_subnet_id, modification_ts from dhcp6_pool"
578+
run_statement "dhcp6_pool" "$qry"
632579

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

639584
# table: dhcp6_options_server
640-
qry="select option_id, server_id, modification_ts from dhcp6_options_server";
641-
count=`mysql_execute "${qry}"`
642-
ERRCODE=$?
643-
assert_eq 0 $ERRCODE "dhcp6_options_server table missing or broken (expected status code %d, returned %d)";
585+
qry="select option_id, server_id, modification_ts from dhcp6_options_server"
586+
run_statement "dhcp6_options_server" "$qry"
644587

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

0 commit comments

Comments
 (0)