From 9ae2b5b8a08f0fc91ace6b3b7d9d9593c7bc3c43 Mon Sep 17 00:00:00 2001
From: "Dmitry E. Oboukhov" <unera@debian.org>
Date: Mon, 2 Jul 2012 17:05:50 +0400
Subject: [PATCH] pending is able to start its own tarantool for tests

---
 connector/perl/t/03-box.t                     |  3 +-
 connector/perl/t/{pending.pl => 04-pending.t} | 95 ++++++-------------
 connector/perl/t/data/pending.t.cfg           | 62 ++++++++++++
 3 files changed, 93 insertions(+), 67 deletions(-)
 rename connector/perl/t/{pending.pl => 04-pending.t} (64%)
 create mode 100644 connector/perl/t/data/pending.t.cfg

diff --git a/connector/perl/t/03-box.t b/connector/perl/t/03-box.t
index 56a4f6a2cb..cfe66e264c 100644
--- a/connector/perl/t/03-box.t
+++ b/connector/perl/t/03-box.t
@@ -53,11 +53,12 @@ ok -r $tarantool_config, "-r $tarantool_config";
 
 
 our $server = shift || $ENV{BOX};
+my $tnt_srv;
 
 SKIP: {
     skip 'The test uses external tarantool instance', 2 if $server;
 
-    my $tnt_srv = Test::Tarantool->run(cfg => $tarantool_config);
+    $tnt_srv = Test::Tarantool->run(cfg => $tarantool_config);
     ok $tnt_srv, 'server instance created';
     diag $tnt_srv->log unless ok $tnt_srv->started, 'server is started';
 
diff --git a/connector/perl/t/pending.pl b/connector/perl/t/04-pending.t
similarity index 64%
rename from connector/perl/t/pending.pl
rename to connector/perl/t/04-pending.t
index f0db3b360f..24802a139a 100644
--- a/connector/perl/t/pending.pl
+++ b/connector/perl/t/04-pending.t
@@ -11,14 +11,19 @@ BEGIN {
 }
 use FindBin qw($Bin);
 use lib "$Bin";
+use lib "$Bin/../lib";
+
 use Carp qw/confess/;
 
-use Test::More tests => 24;
+use Test::More tests => 29;
 use Test::Exception;
 
 use List::MoreUtils qw/zip/;
 
-use MR::Pending;
+BEGIN {
+    use_ok 'Test::Tarantool';
+    use_ok 'MR::Pending';
+}
 
 local $SIG{__DIE__} = \&confess;
 
@@ -35,7 +40,25 @@ use constant NO_SUCCESS        => qr/no success after/;
 use constant TOO_BIG_FIELD => qr/too big field/;
 
 our $box;
-our $server = (shift || $ENV{BOX}) or die;
+
+
+our $server = shift || $ENV{BOX};
+
+my $tarantool_config = "$Bin/data/pending.t.cfg";
+ok -r $tarantool_config, "-r $tarantool_config";
+my $tnt_srv;
+
+SKIP: {
+    skip 'The test uses external tarantool', 2 if $server;
+
+    $tnt_srv = Test::Tarantool->run(cfg => $tarantool_config);
+    ok $tnt_srv, 'server instance created';
+    diag $tnt_srv->log unless ok $tnt_srv->started, 'server is started';
+
+    $server = sprintf '127.0.0.1:%d', $tnt_srv->primary_port;
+}
+
+
 our %opts = (
     debug => $ENV{DEBUG}||0,
     ipdebug => $ENV{IPDEBUG}||0,
@@ -49,6 +72,8 @@ sub cleanup ($) {
     ok $box->Delete($id) == 0, 'delete of non existing record';
 }
 
+
+
 sub def_param  {
     my $format = shift || 'l& SSLL';
     return { servers => $server,
@@ -145,66 +170,4 @@ MR::Pending->new(
 
 
 
-__END__
-
-space[0].enabled = 1
-space[0].index[0].type = "HASH"
-space[0].index[0].unique = 1
-space[0].index[0].key_field[0].fieldno = 0
-space[0].index[0].key_field[0].type = "NUM"
-space[0].index[1].type = "HASH"
-space[0].index[1].unique = 1
-space[0].index[1].key_field[0].fieldno = 1
-space[0].index[1].key_field[0].type = "STR"
-
-space[20].enabled = 1
-space[20].index[0].type = "HASH"
-space[20].index[0].unique = 1
-space[20].index[0].key_field[0].fieldno = 0
-space[20].index[0].key_field[0].type = "NUM64"
-
-
-space[26].enabled = 1
-space[26].index[0].type = "HASH"
-space[26].index[0].unique = 1
-space[26].index[0].key_field[0].fieldno = 0
-space[26].index[0].key_field[0].type = "NUM"
-space[26].index[1].type = "TREE"
-space[26].index[1].unique = 0
-space[26].index[1].key_field[0].fieldno = 1
-space[26].index[1].key_field[0].type = "STR"
-space[26].index[2].type = "TREE"
-space[26].index[2].unique = 0
-space[26].index[2].key_field[0].fieldno = 1
-space[26].index[2].key_field[0].type = "STR"
-space[26].index[2].key_field[1].fieldno = 2
-space[26].index[2].key_field[1].type = "NUM"
-
-
-
-space[27].enabled = 1
-space[27].index[0].type = "HASH"
-space[27].index[0].unique = 1
-space[27].index[0].key_field[0].fieldno = 0
-space[27].index[0].key_field[0].type = "NUM"
-space[27].index[1].type = "HASH"
-space[27].index[1].unique = 1
-space[27].index[1].key_field[0].fieldno = 1
-space[27].index[1].key_field[0].type = "STR"
-
-space[27].index[2].type = "TREE"
-space[27].index[2].unique = 1
-space[27].index[2].key_field[0].fieldno = 2
-space[27].index[2].key_field[0].type = "STR"
-
-space[27].index[2].type = "TREE"
-space[27].index[2].unique = 1
-space[27].index[2].key_field[0].fieldno = 3
-space[27].index[2].key_field[0].type = "STR"
-
-space[27].index[3].type = "TREE"
-space[27].index[3].unique = 1
-space[27].index[3].key_field[0].fieldno = 2
-space[27].index[3].key_field[0].type = "STR"
-space[27].index[3].key_field[1].fieldno = 3
-space[27].index[3].key_field[1].type = "STR"
+
diff --git a/connector/perl/t/data/pending.t.cfg b/connector/perl/t/data/pending.t.cfg
new file mode 100644
index 0000000000..1dbbbcbc50
--- /dev/null
+++ b/connector/perl/t/data/pending.t.cfg
@@ -0,0 +1,62 @@
+space[0].enabled = 1
+space[0].index[0].type = "HASH"
+space[0].index[0].unique = 1
+space[0].index[0].key_field[0].fieldno = 0
+space[0].index[0].key_field[0].type = "NUM"
+space[0].index[1].type = "HASH"
+space[0].index[1].unique = 1
+space[0].index[1].key_field[0].fieldno = 1
+space[0].index[1].key_field[0].type = "STR"
+
+space[20].enabled = 1
+space[20].index[0].type = "HASH"
+space[20].index[0].unique = 1
+space[20].index[0].key_field[0].fieldno = 0
+space[20].index[0].key_field[0].type = "NUM64"
+
+
+space[26].enabled = 1
+space[26].index[0].type = "HASH"
+space[26].index[0].unique = 1
+space[26].index[0].key_field[0].fieldno = 0
+space[26].index[0].key_field[0].type = "NUM"
+space[26].index[1].type = "TREE"
+space[26].index[1].unique = 0
+space[26].index[1].key_field[0].fieldno = 1
+space[26].index[1].key_field[0].type = "STR"
+space[26].index[2].type = "TREE"
+space[26].index[2].unique = 0
+space[26].index[2].key_field[0].fieldno = 1
+space[26].index[2].key_field[0].type = "STR"
+space[26].index[2].key_field[1].fieldno = 2
+space[26].index[2].key_field[1].type = "NUM"
+
+
+
+space[27].enabled = 1
+space[27].index[0].type = "HASH"
+space[27].index[0].unique = 1
+space[27].index[0].key_field[0].fieldno = 0
+space[27].index[0].key_field[0].type = "NUM"
+space[27].index[1].type = "HASH"
+space[27].index[1].unique = 1
+space[27].index[1].key_field[0].fieldno = 1
+space[27].index[1].key_field[0].type = "STR"
+
+space[27].index[2].type = "TREE"
+space[27].index[2].unique = 1
+space[27].index[2].key_field[0].fieldno = 2
+space[27].index[2].key_field[0].type = "STR"
+
+space[27].index[2].type = "TREE"
+space[27].index[2].unique = 1
+space[27].index[2].key_field[0].fieldno = 3
+space[27].index[2].key_field[0].type = "STR"
+
+space[27].index[3].type = "TREE"
+space[27].index[3].unique = 1
+space[27].index[3].key_field[0].fieldno = 2
+space[27].index[3].key_field[0].type = "STR"
+space[27].index[3].key_field[1].fieldno = 3
+space[27].index[3].key_field[1].type = "STR"
+
-- 
GitLab