MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
have_clusterj.inc
1 --perl
2 use strict;
3 
4 use File::Basename;
5 use IO::File;
6 use lib "lib/";
7 use My::Find;
8 
9 #
10 # Look for Cluster/J library, if not found: skip test.
11 #
12 
13 #
14 # Set up paths
15 #
16 my $vardir = $ENV{MYSQLTEST_VARDIR} or die "Need MYSQLTEST_VARDIR";
17 my $mysql_test_dir = $ENV{MYSQL_TEST_DIR} or die "Need MYSQL_TEST_DIR";
18 my $basedir = dirname($mysql_test_dir);
19 
20 #
21 # Check if the needed jars and libs are available
22 #
23 
24 my $clusterj_jar = my_find_file($basedir,
25  ["storage/ndb/clusterj",
26  "share/mysql/java", # install unix
27  "lib/java"], # install windows
28  "clusterj-*.jar", NOT_REQUIRED);
29 
30 my $clusterj_test_jar = my_find_file($basedir,
31  ["storage/ndb/clusterj/clusterj-test",
32  "share/mysql/java", # install unix
33  "lib/java"], # install windows
34  "clusterj-test-*.jar", NOT_REQUIRED);
35 
36 my $ndbclient_lib = my_find_file($basedir,
37  ["storage/ndb/src/.libs",
38  "storage/ndb/src",
39  "lib/mysql",
40  "lib"],
41  ["ndbclient.dll", "libndbclient.so", "libndbclient.dylib"],
42  NOT_REQUIRED);
43 
44 my $F = IO::File->new("$vardir/tmp/have_clusterj_result.inc", 'w') or die;
45 if ($clusterj_jar) {
46  print $F "--let \$CLUSTERJ_JAR= $clusterj_jar\n";
47  print $F "--echo Found clusterj.jar: '\$CLUSTERJ_JAR'\n"
48 } else {
49  print $F "skip Could not find clusterj jar file\n";
50 }
51 
52 if ($clusterj_test_jar) {
53  print $F "--let \$CLUSTERJ_TEST_JAR= $clusterj_test_jar\n";
54  print $F "--echo Found clusterj_test jar: '\$CLUSTERJ_TEST_JAR'\n"
55 } else {
56  print $F "skip Could not find clusterj test jar file\n";
57 }
58 
59 if ($ndbclient_lib) {
60  my $ndbclient_lib_dir = dirname($ndbclient_lib);
61  print $F "--let \$NDBCLIENT_LIB_DIR= $ndbclient_lib_dir\n";
62 } else {
63  print $F "skip Did not find libndbclient\n";
64 }
65 
66 $F->close();
67 
68 write_properties();
69 
70 sub add {
71  my $F = shift;
72  my $prop = shift;
73  my $val = shift;
74  print $F "com.mysql.clusterj.$prop=$val\n";
75 }
76 
77 sub write_properties {
78  my $db = 'test';
79  my $user = 'root';
80  my $F = IO::File->new("$vardir/tmp/clusterj.properties", 'w') or die;
81  add($F, 'connectstring', $ENV{'NDB_CONNECTSTRING'});
82  add($F, 'connect.retries', '4');
83  add($F, 'connect.delay', '5');
84  add($F, 'connect.verbose', '1');
85  add($F, 'connect.timeout.before', '30');
86  add($F, 'connect.timeout.after', '20');
87  add($F, 'jdbc.url', "jdbc:mysql://localhost:$ENV{MASTER_MYPORT}/$db");
88  add($F, 'jdbc.driver', 'com.mysql.jdbc.Driver');
89  add($F, 'jdbc.username', $user);
90  add($F, 'jdbc.password', '');
91  add($F, 'username', '');
92  add($F, 'password', '');
93  add($F, 'database', $db);
94  add($F, 'max.transactions', '1024');
95  $F->close();
96 }
97 
98 EOF
99 
100 --source $MYSQLTEST_VARDIR/tmp/have_clusterj_result.inc