1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
#!/usr/bin/env perl -w
use strict;
use warnings;
use lib 'blib/lib';
use lib 't/lib';
use NetApp::Test;
BEGIN {
if ( not @NetApp::Test::filer_args ) {
print "1..0 # Skipped: No test filers defined\n";
exit 0;
}
}
use Test::More qw( no_plan );
use Test::Exception;
use Data::Dumper;
use NetApp::Filer;
use NetApp::Aggregate;
use NetApp::Volume;
use NetApp::Snapmirror;
my @volume_names = ();
foreach my $filer_args ( @NetApp::Test::filer_args ) {
ok( ref $filer_args eq 'HASH',
'filer_args entry is a HASH ref' );
my $filer = NetApp::Filer->new( $filer_args );
isa_ok( $filer, 'NetApp::Filer' );
print "# Running tests on filer " . $filer->get_hostname . "\n";
my @snapmirrors = $filer->get_snapmirrors;
@volume_names = ();
foreach my $snapmirror ( @snapmirrors ) {
test_snapmirror(
snapmirror => $snapmirror,
volume_names => 1,
);
}
foreach my $volume_name ( @volume_names ) {
my $volume = $filer->get_volume( $volume_name );
isa_ok( $volume, 'NetApp::Volume' );
my @volume_snapmirrors = $volume->get_snapmirrors;
ok( @volume_snapmirrors,'volume->get_snapmirrors returns list' );
foreach my $volume_snapmirror ( @volume_snapmirrors ) {
test_snapmirror(
snapmirror => $volume_snapmirror,
);
}
}
}
sub test_snapmirror {
my (%args) = @_;
my $snapmirror = $args{snapmirror};
isa_ok( $snapmirror, 'NetApp::Snapmirror' );
my $hostname = $snapmirror->get_filer->get_hostname;
if ( my $source = $snapmirror->get_source ) {
isa_ok( $source, 'NetApp::Snapmirror::Source' );
my $source_hostname = $source->get_hostname;
ok( $source_hostname,
"source->get_hostname: $source_hostname" );
my $source_volume = $source->get_volume;
ok( $source_volume,
"source->get_volume: $source_volume" );
if ( $args{volume_names} &&
same_hostname( $hostname, $source_hostname ) ) {
push @volume_names, $source_volume;
}
}
my $destination = $snapmirror->get_destination;
isa_ok( $destination, 'NetApp::Snapmirror::Destination' );
my $dest_hostname = $destination->get_hostname;
ok( $dest_hostname,
"destination->get_hostname: $dest_hostname" );
my $dest_volume = $destination->get_volume;
ok( $dest_volume,
"destination->get_volume: $dest_volume" );
if ( $args{volume_names} &&
same_hostname( $hostname, $dest_hostname ) ) {
push @volume_names, $dest_volume;
}
my @keys = qw( status progress state lag
mirror_timestamp base_snapshot
current_transfer_type current_transfer_error
contents
last_transfer_type last_transfer_size
last_transfer_duration last_transfer_from );
foreach my $key ( @keys ) {
my $method = "get_$key";
my $value = $snapmirror->$method;
ok( defined $value, "snapmirror->$method: '$value'" );
}
}
#
# Crude comparison of hostnames. If both are FQDNs, they must be an
# exact match, otherwise, just compare the base hostnames.
#
sub same_hostname {
my ($first,$second) = @_;
if ( $first =~ /\./ && $second =~ /\./ ) {
return $first eq $second;
} else {
($first) = split( /\./, $first );
($second) = split( /\./, $second );
return $first eq $second;
}
}
|