Craftworks > Test-ttserver > Test::ttserver

Download:
Test-ttserver-0.003.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.003   Source  

NAME ^

Test::ttserver - ttserver runner for tests

SYNOPSIS ^

  use Test::More;
  use Test::ttserver;
  use TokyoTyrant;

  my $ttserver = Test::ttserver->new
      or plan 'skip_all' => $Test::ttserver::errstr;

  plan 'tests' => XXX;

  my $rdb = TokyoTyrant::RDB->new;
  $rdb->open( $ttserver->socket );
  ...

DESCRIPTION ^

Test::ttserver automatically setups a ttserver instance in a temporary directory, and destroys it when the perl script exits.

ttserver is the managing server of the database instance of the Tokyo Tyrant that is a network interface of the Tokyo Cabinet.

CONSTRUCTOR ^

  # on memory database
  my $ttserver = Test::ttserver->new(undef,
      debug => 1,
      port  => 101978,
  );

  Ex.) Dual Master

  # ttserver -port 1978 -ulog ulog-a -sid 1 -mhost localhost \
  #     -mport 1979 -rts a.rts casket-a.tch
  my $ttserver_a = Test::ttserver->new('casket-a.tch',
      port  => 1978,
      ulog  => 'ulog-a',
      sid   => 1,
      mhost => 'localhost',
      mport => 1979,
      rts   => 'a.rts',
  ) or plan 'skip_all' => $Test::ttserver::errstr;

  # ttserver -port 1979 -ulog ulog-b -sid 2 -mhost localhost \
  #     -mport 1978 -rts b.rts casket-b.tch
  my $ttserver_b = Test::ttserver->new('casket-b.tch',
      port  => 1979,
      ulog  => 'ulog-b',
      sid   => 2,
      mhost => 'localhost',
      mport => 1978,
      rts   => 'b.rts',
  ) or plan 'skip_all' => $Test::ttserver::errstr;

METHODS ^

new( [$dbname] [, %options] )

Create and run a ttserver instance. The instance is terminated when the returned object is being DESTROYed. If required programs (ttserver) were not found, the function returns undef and sets appropriate message to $Test::ttserver::errstr.

ttserver ups as "on memory database" if $dbname is specified undef.

$dbname must be named *.tch or *.tcb or *.tcf. See also the manual of Tokyo Tyrant and Tokyo Cabinet for details.

base_dir

Returns directory under which the ttserver instance is being created. The property can be set as a parameter of the new function, in which case the directory will not be removed at exit.

pid

Returns process id of ttserver (or undef if not running).

socket

host

port

returns the host and port where server is bound on.

start

Starts ttserver. returns process id of ttserver if succeed.

stop

Stops ttserver. returns true if succeed.

setup

Setups the ttserver instance.

returns port where server is bound on.

is_up

is_down

returns the value of boolean that server is up or down.

pid_file

returns the file path of process id of ttserver.

args

returns the argument values when ttserver was started.

SEE ALSO ^

TokyoTyrant, TokyoCabinet

http://fallabs.com/tokyotyrant/
http://fallabs.com/tokyocabinet/

AUTHOR ^

Craftworks, <craftwork at cpan org>

BUGS ^

Please report any bugs or feature requests to bug-test-ttserver@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT ^

Copyright (C) 2009 Craftworks, All Rights Reserved.

LICENSE ^

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

syntax highlighting: