Subversion Repositories zfs_utils

Rev

Rev 62 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 62 Rev 63
Line 151... Line 151...
151
# Summary
151
# Summary
152
print "\n";
152
print "\n";
153
print "=" x 60 . "\n";
153
print "=" x 60 . "\n";
154
print "Test Summary\n";
154
print "Test Summary\n";
155
print "=" x 60 . "\n";
155
print "=" x 60 . "\n";
156
print "All tests completed. Review output above for details.\n";
156
print "All basic tests completed. Review output above for details.\n";
157
print "Note: Dry-run mode ensures no actual writes were performed.\n";
157
print "Note: Dry-run mode ensures no actual writes were performed.\n";
158
print "\n";
158
print "\n";
159
 
159
 
-
 
160
# Test 6: Target mode simulation
-
 
161
print "=" x 60 . "\n";
-
 
162
print "Test 6: Target Mode Simulation\n";
-
 
163
print "=" x 60 . "\n";
-
 
164
print "Note: This test simulates running on the target server\n";
-
 
165
print "      by temporarily overriding the hostname.\n\n";
-
 
166
 
-
 
167
# Read the config to get the target hostname
-
 
168
my $target_hostname;
-
 
169
if (open my $cfg_fh, '<', $config_file) {
-
 
170
    while (my $line = <$cfg_fh>) {
-
 
171
        if ($line =~ /^\s*hostname:\s*['"]?([^'"]+)['"]?\s*$/) {
-
 
172
            # This is a bit crude, but we need to find target.hostname
-
 
173
            # We'll look for it after we see 'target:' section
-
 
174
            my $in_target = 0;
-
 
175
            seek($cfg_fh, 0, 0);  # Reset to beginning
-
 
176
            while (my $l2 = <$cfg_fh>) {
-
 
177
                if ($l2 =~ /^target:/) {
-
 
178
                    $in_target = 1;
-
 
179
                    next;
-
 
180
                }
-
 
181
                if ($in_target && $l2 =~ /^\s*hostname:\s*['"]?([^'"]+)['"]?\s*$/) {
-
 
182
                    $target_hostname = $1;
-
 
183
                    last;
-
 
184
                }
-
 
185
                if ($in_target && $l2 =~ /^[a-z]+:/ && $l2 !~ /^\s/) {
-
 
186
                    $in_target = 0;  # Exited target section
-
 
187
                }
-
 
188
            }
-
 
189
            last;
-
 
190
        }
-
 
191
    }
-
 
192
    close $cfg_fh;
-
 
193
}
-
 
194
 
-
 
195
if ($target_hostname) {
-
 
196
    print "Target hostname from config: $target_hostname\n";
-
 
197
    print "Running sneakernet with HOSTNAME=$target_hostname\n";
-
 
198
    print "-" x 60 . "\n\n";
-
 
199
    
-
 
200
    # Set environment variable to simulate target hostname
-
 
201
    local $ENV{HOSTNAME} = $target_hostname;
-
 
202
    
-
 
203
    my $target_output = `HOSTNAME=$target_hostname perl $sneakernet_script --dryrun -vvv 2>&1`;
-
 
204
    my $target_exit = $? >> 8;
-
 
205
    
-
 
206
    print "Output:\n";
-
 
207
    print $target_output;
-
 
208
    print "\n";
-
 
209
    print "-" x 60 . "\n";
-
 
210
    print "Exit code: $target_exit\n";
-
 
211
    
-
 
212
    # Analyze the output for target-specific behavior
-
 
213
    my $detected_target = $target_output =~ /target|receiving|import/i;
-
 
214
    my $has_receive = $target_output =~ /zfs receive/i;
-
 
215
    my $has_geli = $target_output =~ /geli|decrypt|mount/i;
-
 
216
    
-
 
217
    print "\nTarget Mode Analysis:\n";
-
 
218
    print "  Running as target: " . ($detected_target ? "Yes" : "No") . "\n";
-
 
219
    print "  Contains zfs receive: " . ($has_receive ? "Yes" : "No") . "\n";
-
 
220
    print "  Contains GELI operations: " . ($has_geli ? "Yes" : "No") . "\n";
-
 
221
    
-
 
222
    if ($target_exit == 0) {
-
 
223
        print "\n✓ PASS: Target mode dry-run completed successfully\n";
-
 
224
    } else {
-
 
225
        print "\n✗ FAIL: Target mode dry-run exited with error code $target_exit\n";
-
 
226
    }
-
 
227
} else {
-
 
228
    print "⚠ SKIP: Could not determine target hostname from config\n";
-
 
229
    print "        Target mode test skipped.\n";
-
 
230
}
-
 
231
 
-
 
232
print "\n";
-
 
233
print "=" x 60 . "\n";
-
 
234
print "All Tests Complete\n";
-
 
235
print "=" x 60 . "\n";
-
 
236
print "\n";
-
 
237
 
160
1;
238
1;