~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/mtr_process.pl

Merge of Jay

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($$$);
35
34
sub mtr_exit ($);
36
35
sub sleep_until_file_created ($$$);
37
36
sub mtr_kill_processes ($);
360
359
              "socket: '$srv->{path_sock}'; ".
361
360
              "port: $srv->{port})");
362
361
 
363
 
    my $pid= mtr_mysqladmin_start($srv, "shutdown", 20);
 
362
    my $pid= mtr_server_shutdown($srv);
364
363
 
365
 
    # Save the pid of the mysqladmin process
 
364
    # Save the pid of the drizzle client process
366
365
    $admin_pids{$pid}= 1;
367
366
 
368
367
    push(@kill_pids,{
374
373
    $srv->{'pid'}= 0; # Assume we are done with it
375
374
  }
376
375
 
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
 
 
417
376
  # Wait for all the admin processes to complete
418
377
  mtr_wait_blocking(\%admin_pids);
419
378
 
563
522
  # many process's will exit sucessfully.
564
523
  # This is the normal case.
565
524
  # ----------------------------------------------------------------------
566
 
  my $wait_counter= 50; # Max number of times to redo the loop
 
525
  my $wait_counter= 100; # Max number of times to redo the loop
567
526
  foreach my $srv ( @$spec )
568
527
  {
569
528
    my $pid= $srv->{'pid'};
713
672
  }
714
673
}
715
674
 
716
 
# Start "mysqladmin <command>" for a specific mysqld
717
 
sub mtr_mysqladmin_start($$$) {
 
675
sub mtr_server_shutdown($) {
718
676
  my $srv= shift;
719
 
  my $command= shift;
720
 
  my $adm_shutdown_tmo= shift;
721
 
 
722
677
  my $args;
 
678
 
723
679
  mtr_init_args(\$args);
724
 
 
725
 
  mtr_add_arg($args, "--no-defaults");
 
680
  mtr_add_arg($args, "--shutdown");
726
681
  mtr_add_arg($args, "--user=%s", $::opt_user);
727
682
  mtr_add_arg($args, "--password=");
728
683
  mtr_add_arg($args, "--silent");
 
684
 
729
685
  if ( -e $srv->{'path_sock'} )
730
686
  {
731
687
    mtr_add_arg($args, "--socket=%s", $srv->{'path_sock'});
732
688
  }
 
689
 
733
690
  if ( $srv->{'port'} )
734
691
  {
735
692
    mtr_add_arg($args, "--port=%s", $srv->{'port'});
736
693
  }
 
694
 
737
695
  mtr_add_arg($args, "--connect_timeout=5");
738
696
 
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");
 
697
  my $pid= mtr_spawn($::exe_drizzle, $args,
 
698
                     "", "", "", "", { append_log_file => 1 });
 
699
  mtr_verbose("mtr_server_shutdown, pid: $pid");
746
700
  return $pid;
747
 
 
748
701
}
749
702
 
750
703
# Start "ndb_mgm shutdown" for a specific cluster, it will