~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/mtr_process.pl

  • Committer: Monty Taylor
  • Date: 2008-11-16 06:29:53 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116062953-ivdltjmfe009b5fr
Moved stuff into item/

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
sub mtr_wait_blocking ($);
32
32
sub mtr_record_dead_children ();
33
33
sub mtr_ndbmgm_start($$);
 
34
sub mtr_mysqladmin_start($$$);
34
35
sub mtr_exit ($);
35
36
sub sleep_until_file_created ($$$);
36
37
sub mtr_kill_processes ($);
359
360
              "socket: '$srv->{path_sock}'; ".
360
361
              "port: $srv->{port})");
361
362
 
362
 
    my $pid= mtr_server_shutdown($srv);
 
363
    my $pid= mtr_mysqladmin_start($srv, "shutdown", 20);
363
364
 
364
 
    # Save the pid of the drizzle client process
 
365
    # Save the pid of the mysqladmin process
365
366
    $admin_pids{$pid}= 1;
366
367
 
367
368
    push(@kill_pids,{
373
374
    $srv->{'pid'}= 0; # Assume we are done with it
374
375
  }
375
376
 
 
377
  if ( ! $::opt_skip_ndbcluster )
 
378
  {
 
379
 
 
380
    foreach my $cluster (@{$::clusters})
 
381
    {
 
382
 
 
383
      # Don't shut down a "running" cluster
 
384
      next if $cluster->{'use_running'};
 
385
 
 
386
      mtr_debug("  - cluster " .
 
387
                "(pid: $cluster->{pid}; " .
 
388
                "pid file: '$cluster->{path_pid})");
 
389
 
 
390
      my $pid= mtr_ndbmgm_start($cluster, "shutdown");
 
391
 
 
392
      # Save the pid of the ndb_mgm process
 
393
      $admin_pids{$pid}= 1;
 
394
 
 
395
      push(@kill_pids,{
 
396
                       pid      => $cluster->{'pid'},
 
397
                       pidfile  => $cluster->{'path_pid'}
 
398
                      });
 
399
 
 
400
      $cluster->{'pid'}= 0; # Assume we are done with it
 
401
 
 
402
      foreach my $ndbd (@{$cluster->{'ndbds'}})
 
403
      {
 
404
        mtr_debug("    - ndbd " .
 
405
                  "(pid: $ndbd->{pid}; " .
 
406
                  "pid file: '$ndbd->{path_pid})");
 
407
 
 
408
        push(@kill_pids,{
 
409
                         pid      => $ndbd->{'pid'},
 
410
                         pidfile  => $ndbd->{'path_pid'},
 
411
                        });
 
412
        $ndbd->{'pid'}= 0; # Assume we are done with it
 
413
      }
 
414
    }
 
415
  }
 
416
 
376
417
  # Wait for all the admin processes to complete
377
418
  mtr_wait_blocking(\%admin_pids);
378
419
 
522
563
  # many process's will exit sucessfully.
523
564
  # This is the normal case.
524
565
  # ----------------------------------------------------------------------
525
 
  my $wait_counter= 10; # Max number of times to redo the loop
 
566
  my $wait_counter= 50; # Max number of times to redo the loop
526
567
  foreach my $srv ( @$spec )
527
568
  {
528
569
    my $pid= $srv->{'pid'};
541
582
        if ($wait_counter-- > 0)
542
583
        {
543
584
          # Give the processes more time to exit
544
 
          select(undef, undef, undef, (1));
 
585
          select(undef, undef, undef, (0.1));
545
586
          redo;
546
587
        }
547
588
      }
672
713
  }
673
714
}
674
715
 
675
 
sub mtr_server_shutdown($) {
 
716
# Start "mysqladmin <command>" for a specific mysqld
 
717
sub mtr_mysqladmin_start($$$) {
676
718
  my $srv= shift;
 
719
  my $command= shift;
 
720
  my $adm_shutdown_tmo= shift;
 
721
 
677
722
  my $args;
678
 
 
679
723
  mtr_init_args(\$args);
680
 
  mtr_add_arg($args, "--shutdown");
 
724
 
 
725
  mtr_add_arg($args, "--no-defaults");
681
726
  mtr_add_arg($args, "--user=%s", $::opt_user);
682
727
  mtr_add_arg($args, "--password=");
683
728
  mtr_add_arg($args, "--silent");
684
 
 
685
729
  if ( -e $srv->{'path_sock'} )
686
730
  {
687
731
    mtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
688
732
  }
689
 
 
690
733
  if ( $srv->{'port'} )
691
734
  {
692
735
    mtr_add_arg($args, "--port=%s", $srv->{'port'});
693
736
  }
694
 
 
695
737
  mtr_add_arg($args, "--connect_timeout=5");
696
738
 
697
 
  my $pid= mtr_spawn($::exe_drizzle, $args,
698
 
                     "", "", "", "", { append_log_file => 1 });
699
 
  mtr_verbose("mtr_server_shutdown, pid: $pid");
 
739
  # Shutdown time must be high as slave may be in reconnect
 
740
  mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
 
741
  mtr_add_arg($args, "$command");
 
742
  my $pid= mtr_spawn($::exe_drizzleadmin, $args,
 
743
                     "", "", "", "",
 
744
                     { append_log_file => 1 });
 
745
  mtr_verbose("mtr_mysqladmin_start, pid: $pid");
700
746
  return $pid;
 
747
 
701
748
}
702
749
 
703
750
# Start "ndb_mgm shutdown" for a specific cluster, it will