Skip to content

Commit 6ece0c3

Browse files
committed
test(lab): add unit test test_issue_810.t for issue 810
1 parent 0b5c859 commit 6ece0c3

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

Changelog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
2.9.0 2026-06-15
44

5+
- feat(report): categorize recommendations in HTML report and add Connections/Performance panels, Storage engines table, and SQL modeling stats grid.
6+
- test(report): update HTML report unit tests to verify connections, performance, storage, and modeling HTML sections.
57
- chore(main): whitelist deps and system commit scopes in check_compliance.pl to support Dependabot and host metrics commits.
68
- chore(main): add roadmap to the whitelist of allowed scopes in compliance checks.
79
- feat(cli): create an agent-ready output format (JSON/YAML) so that MySQLTuner can be easily integrated by AI agents.
@@ -31,6 +33,9 @@
3133
- test(lab): add unit test test_issue_480.t for table_open_cache_instances recommendation (#480)
3234
- test(lab): split unit_coverage_boost4.t into smaller topic-oriented unit tests: unit_cli_helpers.t, unit_client_privileges.t, unit_cloud_commands.t, unit_fs_info.t, unit_os_vm.t
3335
- test(lab): normalize all repro_issue_*.t and issue_*.t test file names to test_issue_*.t
36+
- test(lab): add unit test test_issue_810.t for remote host forcemem MB interpretation correctness (issue #810)
37+
- docs(roadmap): specify Phase XVI (AI Agent Integration) and Phase XVII (Dockerized MCP Daemon).
38+
3439

3540

3641
2.8.45 2026-06-04

tests/test_issue_810.t

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env perl
2+
use strict;
3+
use warnings;
4+
no warnings 'once';
5+
use Test::More;
6+
use File::Basename;
7+
use File::Spec;
8+
9+
my $script = File::Spec->rel2abs(File::Spec->catfile(dirname(__FILE__), '..', 'mysqltuner.pl'));
10+
11+
# Mocking and loading mysqltuner.pl
12+
{
13+
local @ARGV = ();
14+
no warnings 'redefine';
15+
require $script;
16+
}
17+
18+
# Silence console printing from within the test
19+
{
20+
no warnings 'redefine';
21+
no warnings 'once';
22+
*main::badprint = sub { };
23+
*main::goodprint = sub { };
24+
*main::debugprint = sub { };
25+
*main::infoprint = sub { };
26+
*main::subheaderprint = sub { };
27+
*main::prettyprint = sub { };
28+
}
29+
30+
# Mock transport and system commands
31+
{
32+
no warnings 'redefine';
33+
no warnings 'once';
34+
*main::get_transport_prefix = sub { return '' };
35+
*main::execute_system_command = sub { return '' };
36+
}
37+
38+
subtest 'Issue 810 - Verify forcemem MB interpretation correctness (regression test)' => sub {
39+
# Initialize basic CLI options metadata defaults
40+
foreach my $o (keys %main::CLI_METADATA) {
41+
my ($p) = split /\|/, $o;
42+
$p =~ s/[!+=:].*$//;
43+
$main::opt{$p} //= $main::CLI_METADATA{$o}->{default};
44+
}
45+
46+
# Simulate `--forcemem 32768` (passed in MB for a 32GB system)
47+
$main::opt{'forcemem'} = 32768;
48+
$main::opt{'forceswap'} = 0;
49+
50+
# Run OS setup logic to calculate physical memory
51+
main::os_setup();
52+
53+
# Verification:
54+
# 32768 MB must equal 34,359,738,368 bytes (32 GB)
55+
is($main::physical_memory, 34359738368, "Physical memory must be correctly calculated in bytes (32768 * 1024 * 1024)");
56+
57+
# Verify that human readable formatting outputs 32.0G and NOT 32.0K (which occurred before the regression fix)
58+
my $pretty = main::hr_bytes($main::physical_memory);
59+
is($pretty, "32.0G", "Pretty memory output must be 32.0G");
60+
isnt($pretty, "32.0K", "Pretty memory output must not be 32.0K (regression check)");
61+
};
62+
63+
done_testing();

0 commit comments

Comments
 (0)