Debian Codegraph @

mysql-test/suite/ndb/include/have_clusterj.inc

raw
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 my $version = $ENV{MYSQL_SERVER_VERSION};
20
21 # In the RPM case, binaries and libraries are installed in the
22 # default system locations, instead of having our own private base
23 # directory. And we install "usr/share/mysql-test". Moving up two
24 # more directory relative to "mysql-test" gives us a usable base
25 # directory for RPM installs.
26 if (! -d "$basedir/sql" and ! -d "$basedir/bin" )
27 {
28 $basedir= dirname($basedir);
29 }
30
31 my $bindir = $ENV{MTR_BINDIR} || $basedir; # Out of source set MTR_BINDIR
32
33 #
34 # Check if the needed jars and libs are available
35 #
36
37 my $clusterj_jar = my_find_file($bindir,
38 [ "storage/ndb/clusterj",
39 "share/java",
40 "share/mysql/java",
41 "share/mysql-8.0/java",
42 "lib/java"
43 ],
44 "clusterj-$version.jar",
45 NOT_REQUIRED);
46
47 my $clusterj_test_jar = my_find_file($bindir,
48 [ "storage/ndb/clusterj/clusterj-test",
49 "share/java",
50 "share/mysql/java",
51 "share/mysql-8.0/java",
52 "lib/java"
53 ],
54 "clusterj-test-$version.jar",
55 NOT_REQUIRED);
56
57 # The expected installation locations are lib, lib/mysql, lib64/mysql, lib/x86_64-linux-gnu
58 my $ndbclient_lib = my_find_file($bindir,
59 [ "library_output_directory",
60 "lib*/*",
61 "lib"
62 ],
63 [ "ndbclient.dll",
64 "libndbclient.so",
65 "libndbclient.dylib"
66 ],
67 NOT_REQUIRED);
68
69 my $F = IO::File->new("$vardir/tmp/have_clusterj_result.inc", 'w') or die;
70 print $F "# Looking for clusterj-$version.jar\n";
71
72 if ($clusterj_jar) {
73 print $F "--let \$CLUSTERJ_JAR= $clusterj_jar\n";
74 print $F "--echo Found clusterj.jar\n"
75 } else {
76 print $F "--let \$skip_test=1\n";
77 print $F "--let \$skip_reason=Could not find clusterj jar file\n";
78 }
79
80 if ($clusterj_test_jar) {
81 print $F "--let \$CLUSTERJ_TEST_JAR= $clusterj_test_jar\n";
82 print $F "--echo Found clusterj_test jar\n"
83 } else {
84 print $F "--let \$skip_test=1\n";
85 print $F "--let \$skip_reason=Could not find clusterj test jar file\n";
86 }
87
88 if ($ndbclient_lib) {
89 my $ndbclient_lib_dir = dirname($ndbclient_lib);
90 print $F "--let \$NDBCLIENT_LIB_DIR= $ndbclient_lib_dir\n";
91 print $F "--echo Found ndbclient library\n"
92 } else {
93 # Test runs only when ndb is compiled and enabled.
94 # If not able to find libndbclient, probably an issue with this script.
95 print $F "die Did not find libndbclient\n";
96 }
97
98 $F->close();
99
100 write_properties();
101
102 sub add {
103 my $F = shift;
104 my $prop = shift;
105 my $val = shift;
106 print $F "com.mysql.clusterj.$prop=$val\n";
107 }
108
109 sub write_properties {
110 my $db = 'test';
111 my $user = 'root';
112 my $F = IO::File->new("$vardir/tmp/clusterj.properties", 'w') or die;
113 add($F, 'connectstring', $ENV{'NDB_CONNECTSTRING'});
114 add($F, 'connect.retries', '4');
115 add($F, 'connect.delay', '5');
116 add($F, 'connect.verbose', '1');
117 add($F, 'connect.timeout.before', '30');
118 add($F, 'connect.timeout.after', '20');
119 add($F, 'jdbc.url', "jdbc:mysql://localhost:$ENV{MASTER_MYPORT}/$db");
120 add($F, 'jdbc.driver', 'com.mysql.cj.jdbc.Driver');
121 add($F, 'jdbc.username', $user);
122 add($F, 'jdbc.password', '');
123 add($F, 'username', '');
124 add($F, 'password', '');
125 add($F, 'database', $db);
126 add($F, 'max.transactions', '1024');
127 $F->close();
128 }
129
130 EOF
131
132 --source $MYSQLTEST_VARDIR/tmp/have_clusterj_result.inc
133 --remove_file $MYSQLTEST_VARDIR/tmp/have_clusterj_result.inc
134
135 # skip if the required jars were not found
136 if ($skip_test) {
137 # remove the clusterj.properties file
138 --remove_file $MYSQLTEST_VARDIR/tmp/clusterj.properties
139 --skip $skip_reason
140 }