Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

hooked up more tests to 'make test'

moxi_mock.pl script is now reusable, at the cost of some (perl
inspired) readability.  It's now invoked to also run the mock auth,
multitenancy, and multitenancy_default tests scripts (combinations of
spawning a fake rest/http server, a moxi with the right params, and
the right python test scripts to drive it).

Change-Id: If7c16c9709ab59320d804909f578c7f9966a7a29
Reviewed-on: http://review.northscale.com/2644
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
commit fa9b090735efaf142dd2c6a884b8ba24d1fd1ecd 1 parent 65fdc5a
Steve Yen steveyen authored

Showing 2 changed files with 96 additions and 7 deletions. Show diff stats Hide diff stats

  1. +44 2 t/moxi_all.pl
  2. +52 5 t/moxi_mock.pl
46 t/moxi_all.pl
@@ -11,6 +11,9 @@
11 11 croak("moxi binary not executable\n") unless -x _;
12 12
13 13 sub go {
  14 + if ($ARGV[0] eq 'mock_only') {
  15 + return;
  16 + }
14 17 my ($topology, $protocol) = @_;
15 18 print "------------------------------------\n";
16 19 print "testing $topology $protocol\n";
@@ -33,10 +36,49 @@ sub go {
33 36 go('simple', 'binary');
34 37 go('fanout', 'binary');
35 38
36   -print "------------------------------------\n";
  39 +print "------------------------------------ ascii\n";
37 40
38 41 my $res = system("./t/moxi_mock.pl ascii");
  42 +if ($res != 0) {
  43 + print "exit: $res\n";
  44 + exit($res);
  45 +}
  46 +
  47 +print "------------------------------------ auth\n";
  48 +
  49 +my $res = system("./t/moxi_mock.pl moxi_mock_auth binary \"\"" .
  50 + " url=http://127.0.0.1:4567/pools/default/buckets/default" .
  51 + " usr=TheUser,pwd=ThePassword,port_listen=11333," .
  52 + " ./t/rest_mock.rb");
  53 +if ($res != 0) {
  54 + print "exit: $res\n";
  55 + exit($res);
  56 +}
  57 +
  58 +sleep(1);
39 59
40   -exit $res;
  60 +print "------------------------------------ multitenancy\n";
  61 +
  62 +my $res = system("./t/moxi_mock.pl moxi_multitenancy binary \"\"" .
  63 + " url=http://127.0.0.1:4567/pools/default/buckets/default" .
  64 + " default_bucket_name=,port_listen=11333," .
  65 + " \"./t/rest_mock.rb ./t/moxi_multitenancy_rest.cfg\"");
  66 +if ($res != 0) {
  67 + print "exit: $res\n";
  68 + exit($res);
  69 +}
  70 +
  71 +sleep(1);
  72 +
  73 +print "------------------------------------ multitenancy_default\n";
  74 +
  75 +my $res = system("./t/moxi_mock.pl moxi_multitenancy_default binary \"\"" .
  76 + " url=http://127.0.0.1:4567/pools/default/buckets/default" .
  77 + " default_bucket_name=default,port_listen=11333," .
  78 + " \"./t/rest_mock.rb ./t/moxi_multitenancy_rest_default.cfg\"");
  79 +if ($res != 0) {
  80 + print "exit: $res\n";
  81 + exit($res);
  82 +}
41 83
42 84
57 t/moxi_mock.pl
@@ -4,15 +4,30 @@
4 4 #
5 5 # ./t/moxi_mock.pl [upstream_protocol] [downstream_protocol] [test_name]
6 6 #
  7 +# An upstream_protocol/downstream_protocol is ascii or binary.
  8 +#
7 9 # Parameters are optional, so these examples work, and default to ascii...
8 10 #
9 11 # ./t/moxi_mock.pl
10 12 # ./t/moxi_mock.pl ascii
11 13 # ./t/moxi_mock.pl ascii ascii TestProxyAscii.testBasicQuit
12 14 #
  15 +# Alternative command-line...
  16 +#
  17 +# ./t/moxi_mock.pl [mock_test] [downstream_protocol] [test_name] \
  18 +# [moxi-z-param] [moxi-Z-param] [rest/http-server-params]
  19 +#
  20 +# ./t/moxi_mock.pl moxi_mock_auth binary "" \
  21 +# url=http://127.0.0.1:4567/pools/default/buckets/default \
  22 +# usr=TheUser,pwd=ThePassword,port_listen=11333, \
  23 +# ./t/rest_mock.rb
  24 +#
13 25 my $upstream_protocol = $ARGV[0] || 'ascii';
14 26 my $downstream_protocol = $ARGV[1] || 'ascii';
15 27 my $test_name = $ARGV[2] || '';
  28 +my $little_z = $ARGV[3] || './t/moxi_mock.cfg';
  29 +my $big_Z = $ARGV[4] || '';
  30 +my $restargs = $ARGV[5] || '...NONE...';
16 31
17 32 print "moxi_mock.pl: " . $upstream_protocol . " " . $downstream_protocol . " " . $test_name + "\n";
18 33
@@ -21,14 +36,33 @@
21 36 croak("moxi binary doesn't exist. Haven't run 'make' ?\n") unless -e $exe;
22 37 croak("moxi binary not executable\n") unless -x _;
23 38
  39 +# Fork rest/http server if necessary.
  40 +#
  41 +my $restpid = -1;
  42 +if ($restargs ne '...NONE...') {
  43 + print($restargs . "\n");
  44 + $restpid = fork();
  45 + unless ($restpid) {
  46 + setpgrp();
  47 + exec "ruby $restargs";
  48 + exit;
  49 + }
  50 + setpgrp($childpid, $childpid);
  51 + sleep(1);
  52 +}
  53 +
24 54 # Fork moxi for moxi-specific testing.
25 55 #
26 56 my $childargs =
27   - " -z ./t/moxi_mock.cfg".
28   - " -p 0 -U 0 -v -t 1 -Z \"downstream_max=1,downstream_protocol=" . $downstream_protocol . "\"";
  57 + " -z ". $little_z .
  58 + " -p 0 -U 0 -v -t 1".
  59 + " -Z \"". $big_Z ."downstream_max=1,downstream_protocol=" . $downstream_protocol . "\"";
29 60 if ($< == 0) {
30 61 $childargs .= " -u root";
31 62 }
  63 +
  64 +print($childargs . "\n");
  65 +
32 66 my $childpid = fork();
33 67
34 68 unless ($childpid) {
@@ -37,12 +71,25 @@
37 71 exit; # never gets here.
38 72 }
39 73 setpgrp($childpid, $childpid);
  74 +sleep(1);
40 75
41   -my $u = substr($upstream_protocol, 0, 1); # This is 'a' or 'b'.
42   -my $d = substr($downstream_protocol, 0, 1); # This is 'a' or 'b'.
  76 +my $result = -1;
43 77
44   -my $result = system("python ./t/moxi_mock_" . $u . "2" . $d . ".py " . $test_name);
  78 +if ($upstream_protocol ne 'ascii' &&
  79 + $upstream_protocol ne 'binary') {
  80 + $result = system("python ./t/" . $ARGV[0] . ".py " . $test_name);
  81 +} else {
  82 + my $u = substr($upstream_protocol, 0, 1); # This is 'a' or 'b'.
  83 + my $d = substr($downstream_protocol, 0, 1); # This is 'a' or 'b'.
  84 +
  85 + $result = system("python ./t/moxi_mock_" . $u . "2" . $d . ".py " . $test_name);
  86 +}
45 87
46 88 kill 2, -$childpid;
47 89
  90 +if ($restpid >= 0) {
  91 + kill 2, -$restpid;
  92 + sleep(1);
  93 +}
  94 +
48 95 exit $result;

0 comments on commit fa9b090

Please sign in to comment.
Something went wrong with that request. Please try again.