Ignore:
Timestamp:
2013-05-27T12:22:03+12:00 (11 years ago)
Author:
jmt12
Message:

Removing DateTime dependency (so HDFSShell will always fail modificationTime()) and making the locating of the resources directory a little more robust

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/bin/script/test_fileutils.pl

    r27436 r27480  
    77# Configure
    88my $user = 'jmt12';
    9 my $hadoop_path = '/mnt/sdb1/jmt12/gsdl2-svn/ext/parallel-building/packages/hadoop-1.1.0';
    109my $redirect_errors = 0;
    1110my $display_errors = 0;
    1211
    13 my $test_localfs = 0;
     12my $test_localfs = 1;
    1413my $test_hdthriftfs = 1;
    15 my $test_hdfsshell = 0;
     14my $test_hdfsshell = 1;
    1615
    1716# Globals
     
    4948    }
    5049  }
     50
     51  # Manually installed CPAN package in GEXT*INSTALL
     52  # - parse up version number
     53  my ($major, $minor, $revision) = $] =~ /(\d+)\.(\d\d\d)(\d\d\d)/;
     54  # - get rid of leading zeros by making them integers
     55  $major += 0;
     56  $minor += 0;
     57  $revision += 0;
     58  # - and add to Perl's path
     59  unshift (@INC, $ENV{'GEXTPARALLELBUILDING_INSTALLED'} . '/lib/perl/' . $major . '.' . $minor . '.' . $revision);
    5160}
    5261
    5362use Cwd;
    54 use DateTime;
    5563use Devel::Peek;
    5664
     
    5866
    5967# populate globals
    60 $base_path = getcwd();
     68$base_path = $ENV{'GEXTPARALLELBUILDING'};
    6169
    6270print "\n";
     
    255263  my ($dir, $base_dir) = @_;
    256264  # setup
    257   my $local_image_path = $base_path . '/../../resources/aurora_australus.jpg';
     265  my $local_image_path = $base_path . '/resources/aurora_australus.jpg';
    258266  my $thrift_copy_path = $dir . '/test_binary_transfer.jpg';
    259267  my $local_copy_path = '/tmp/test_binary_transfer.jpg';
     
    464472{
    465473  my ($dir) = @_;
     474  # setup
    466475  my $patha = $dir . '/alpha.txt';
    467   my $exact_modification_time = time();
    468   #rint STDERR "Exact Modification Time:  $exact_modification_time\n";
     476  my $modification_time = time();
    469477  &FileUtils::filePutContents($patha, 'Hello World');
    470478  my $file_modification_time = &FileUtils::modificationTime($patha);
    471   #rint STDERR "File Modification Time:   $file_modification_time\n";
    472   # Try to find an exact match first
    473   if ($exact_modification_time == $file_modification_time)
    474   {
    475     $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (exact)', 1, 1);
    476   }
    477   # Failing that, we can try a rounded match (for file systems that
    478   # don't store modification times down to the second i.e. HDFSShell)
    479   else
    480   {
    481     $skip_count += &skipAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (exact)');
    482     my ($mod_second, $mod_minute, $mod_hour, $mod_day, $mod_month, $mod_year) = localtime($exact_modification_time);
    483     $mod_year += 1900; # initially years since 1900, silly computer scientists
    484     $mod_month += 1; # in the range [0..11], silly computer scientists
    485     my $mod_datetime = DateTime->new(year      => $mod_year,
    486                                      month     => $mod_month,
    487                                      day       => $mod_day,
    488                                      hour      => $mod_hour,
    489                                      minute    => $mod_minute,
    490                                      second    => 0,
    491                                      time_zone => 'local');
    492     my $start_modification_time = $mod_datetime->epoch();
    493     #rint STDERR "Start Modification Time: $start_modification_time\n";
    494     if ($start_modification_time == $file_modification_time)
    495     {
    496       $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (rounded)', 1, 1);
    497     }
    498     # And finally we just accept any time that lies within the same minute
    499     else
    500     {
    501       $skip_count += &skipAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (rounded)');
    502       $mod_datetime->add( minutes => 1 );
    503       my $end_modification_time = $mod_datetime->epoch();
    504       #rint STDERR "End Modification Time: $end_modification_time\n";
    505       $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc (approximate)', 1, ($start_modification_time <= $file_modification_time && $file_modification_time <= $end_modification_time ? 1 : 0));
    506     }
    507   }
     479  # test
     480  $pass_count += &testAction(\$test_count, 'modificationTime() to determine the last modified time as a linux epoc', $modification_time, $file_modification_time);
    508481  # cleanup
    509482  &FileUtils::removeFiles($patha);
Note: See TracChangeset for help on using the changeset viewer.