forked from apache/sqoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
COMPILING.txt
413 lines (284 loc) · 16.3 KB
/
COMPILING.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
= Compiling
This document explains how to compile Sqoop.
////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
////
== Build Dependencies
Compiling Sqoop requires the following tools:
* Apache ant (1.7.1)
* Java JDK 1.6
Additionally, building the documentation requires these tools:
* asciidoc
* make
* python 2.5+
* xmlto
* tar
* gzip
Furthermore, Sqoop's build can be instrumented with the following:
* findbugs (1.3.9) for code quality checks
* cobertura (1.9.4.1) for code coverage
* checkstyle (5.x) for code style checks
== The Basics
Sqoop is compiled with ant. Type +ant -p+ to see the list of available targets.
Type +ant+ to compile all java sources. You can then run Sqoop with +bin/sqoop+.
If you want to build everything (including the documentation), type
+ant package+. This will appear in the
+build/sqoop-(version)/+ directory.
This version of Sqoop is built against Hadoop 0.23 available from Apache
maven repository by default. These dependencies are obtained via IVY which
downloads the necessary binaries.
== Testing Sqoop
Sqoop has several unit tests which can be run with +ant test+. This command
will run all the "basic" checks against an in-memory database, HSQLDB.
Sqoop also has compatibility tests that check its ability to work with
several third-party databases. To enable these tests, you will need to install
and configure the databases or run them in Docker containers, and download the JDBC drivers for each one.
=== Installing the necessary databases
==== MySQL
Install MySQL server and client 5.0. Download MySQL Connector/J 5.0.8 for
JDBC. Instructions for configuring the MySQL database are in MySQLAuthTest
and DirectMySQLTest.
Use the following system properties to configure connection to the MySQL host used for testing:
sqoop.test.mysql.connectstring.host_url, sqoop.test.mysql.databasename, sqoop.test.mysql.username and
sqoop.test.mysql.password.
Specify these properties on the command line or via the build.properties file. For example:
sqoop.test.mysql.connectstring.host_url=jdbc:mysql://host.example.com/
sqoop.test.mysql.databasename=MYDB
sqoop.test.mysql.username=MYUSR
sqoop.test.mysql.password=MYPWD
If not specified, the default value used for this property is:
jdbc:mysql://localhost/
==== Oracle
Install Oracle Enterprise Edition 10.2.0+. Instructions for configuring the
database are in OracleManagerTest. Download the ojdbc6_g jar.
If running the tests against Oracle XE (Express Edition) - a lot of them will
fail as it does not include the partitioning feature.
Use the following system properties to configure connection to the Oracle host used for testing:
sqoop.test.oracle.connectstring, sqoop.test.oracle.username and sqoop.test.oracle.password.
Specify these properties on the command line or via the build.properties file. For example:
sqoop.test.oracle.connectstring=jdbc:oracle:thin:@//host.example.com/xe
sqoop.test.oracle.username=MYUSR
sqoop.test.oracle.password=MYPWD
If not specified, the default value used for this property is:
jdbc:oracle:thin:@//localhost/xe
Users sqooptest and sqooptest2 should be created prior to running the tests.
SQL script is available in src/test/oraoop/create_users.sql
==== PostgreSQL
Install PostgreSQL 8.3.9. Download the postgresql 8.4 jdbc driver. Instructions
for configuring the database are in PostgresqlTest.
Use the following system properties to configure connection to the PostgreSQL host used for testing:
sqoop.test.postgresql.connectstring.host_url, sqoop.test.postgresql.database, sqoop.test.postgresql.username and
sqoop.test.postgresql.password.
Specify this property on the
command line or via the build.properties file. For example:
sqoop.test.postgresql.connectstring.host_url=jdbc:postgresql://sqoop-dbs.sf.cloudera.com/
sqoop.test.postgresql.database=MYDB
sqoop.test.postgresql.username=MYUSR
sqoop.test.postgresql.password=MYPWD
If not specified, the default value used for this property is:
jdbc:postgresql://localhost/
==== SQL Server
Install SQL Server Express 2012 and create a database instance and
download the appropriate JDBC driver. Instructions for configuring the
database can be found in SQLServerManagerImportManualTest.
Use the following system properties to configure connection to the SQL Server host used for testing:
sqoop.test.sqlserver.connectstring.host_url, sqoop.test.sqlserver.database, sqoop.test.sqlserver.username and
sqoop.test.sqlserver.password.
the URL for the SQL Server host used for testing. Specify this property on the
command line or via the build.properties file. For example:
sqoop.test.sqlserver.connectstring.host_url=jdbc:sqlserver://sqlserverhost:1433
sqoop.test.sqlserver.database=MYDB
ms.sqlserver.username=MYUSR
ms.sqlserver.password=MYPWD
If not specified, the default value used for this property is:
jdbc:sqlserver://sqlserverhost:1433
This can be useful if you have the hostname sqlserverhost mapped to the IP
address of the SQL Server instance.
==== Cubrid
Install Cubrid 9.2.2.0003 and create a database instance and download the
appropriate JDBC driver. Instructions for configuring the database are in
CubridAuthTest, CubridCompatTest, CubridManagerImportTest
and CubridManagerExportTest.
Use the following system properties to configure connection to the Cubrid host used for testing:
sqoop.test.cubrid.connectstring.host_url, sqoop.test.cubrid.connectstring.database,
sqoop.test.cubrid.connectstring.username and sqoop.test.cubrid.connectstring.password.
Specify this property on the command
line or via the build.properties file. For example:
sqoop.test.cubrid.connectstring.host_url=jdbc:cubrid:localhost
sqoop.test.cubrid.connectstring.database=MYDB
sqoop.test.cubrid.connectstring.username=MYUSR
sqoop.test.cubrid.connectstring.password=MYPWD
If not specified, the default value used for this property is:
jdbc:cubrid:localhost
==== DB2
Install DB2 9.74 Express C and download the appropriate JDBC driver.
Instructions for configuring the server can be found in
DB2ManagerImportManualTest.
Use the following system properties to configure connection to the DB2 host used for testing:
sqoop.test.db2.connectstring.host_url, sqoop.test.db2.connectstring.database, sqoop.test.db2.connectstring.username and
sqoop.test.db2.connectstring.password.
Specify this property on
the command line or via build.properties file. For example:
sqoop.test.db2.connectstring.host_url=jdbc:db2://db2host:50000
sqoop.test.db2.connectstring.database=MYDB
sqoop.test.db2.connectstring.username=MYUSR
sqoop.test.db2.connectstring.password=MYPWD
If not specified, the default value used for this property is:
jdbc:db2://db2host:50000
This can be useful if you have the hostname db2host mapped to the IP
address of the DB2 Server instance.
=== Running the Third-party Tests on native database servers
After the third-party databases are installed and configured, run:
++++
ant test -Dthirdparty=true -Dsqoop.thirdparty.lib.dir=/path/to/jdbc/drivers/
++++
This command will run all thirdparty tests except some DB2 tests.
To run these DB2 test, specify the property "manual" instead of "thirdparty"
as follows:
++++
ant test -Dmanual=true -Dsqoop.thirdparty.lib.dir=/path/to/jdbc/drivers/
++++
Note that +sqoop.thirdparty.lib.dir+ can also be specified in
+build.properties+.
=== Setting up and executing third-party tests with databases running in Docker containers
The easiest way to run the Sqoop third party test pack is to start all the necessary database servers in Docker containers. This eliminates the need of installing and setting up 6 different RDBMSs on the development machines and provides a clean database environment every time the tests are executed.
==== Installing docker
The first step is to install a recent version (1.13.0+) of Docker and Docker Compose on your development machine. Please refer to the Docker documentation for the installation instructions for your OS environment:
https://docs.docker.com/engine/installation/
https://docs.docker.com/compose/install/
==== Downloading docker images
MySQL, PostgreSQL, MSSQL, DB2 and Cubrid images are freely available on Docker Hub so they will be pulled automatically by the startup command specified below however the Oracle EE image has to be built manually. Please refer to the README.md file on the below Github project for building instructions:
https://github.com/oracle/docker-images/tree/master/OracleDatabase
Please note that Sqoop third party tests require Oracle Enterprise Edition and the startup command assumes version 12.2.0.1.
==== Starting the Docker containers
A startup script has been added to the Sqoop project to make the Docker container initialization easier:
----
<sqoop_workspace>/src/scripts/thirdpartytest/start-thirdpartytest-db-containers.sh
----
If it is executed without parameters it starts the following services:
.Third party test DB docker services
[width="40%",frame="topbot",options="header"]
|======================
|Service name |Database version
|+mysql+ |MySql 5.7.19
|+postgresql+ |PostgreSQL 9.6.4
|+mssql+ |MSSQL 14.0.1000.169 Developer Edition
|+cubrid+ |Cubrid 10.0
|+oracle+ |Oracle EE 12.2.0.1
|+db2+ |DB2 Express Edition 10.5.0.5-3.10.0
|======================
The script starts up all the services by default but you can override this behavior by specifying the service names in the parameter list. For example if you want to start up mysql and postgresql services only you can execute the script like this:
----
<sqoop_workspace>/src/scripts/thirdpartytest/start-thirdpartytest-db-containers.sh mysql postgresql
----
After the startup script is executed the containers need some time to initialize the databases. You can follow the status of the containers using the docker ps command. If a service is properly initialized you will see a healthy status in the output of the docker ps command. For example the below output means that Cubrid is started up successfully and it is ready to be used but DB2 is still starting up:
----
61c4ef871cbb cubrid/cubrid:10.0 "/entrypoint.sh" 43 seconds ago Up 38 seconds (healthy) 0.0.0.0:33000->33000/tcp sqoop_cubrid_container
158e5421d134 ibmcom/db2express-c:10.5.0.5-3.10.0 "/home/db2inst1/db..." 43 seconds ago Up 40 seconds (health: starting) 22/tcp, 0.0.0.0:50000->50000/tcp sqoop_db2_container
----
Most of the containers need less than 1 minute to start up but DB2 needs ~5 minutes and Oracle needs ~15 minutes. The Docker images need ~17GB free disk space and Docker requires ~5GB of memory to start all of them at the same time.
==== Stopping the Docker containers
You can stop and remove the Docker containers using the following command:
----
<sqoop_workspace>/src/scripts/thirdpartytest/stop-thirdpartytest-db-containers.sh
----
==== Running the third party tests using docker containers
You can execute the third party tests against the DBs running in Docker containers using the following command (replace <path_to_thirdparty_lib_directory> with the path you have the necessary JDBC drivers):
----
ant clean test -Dthirdparty=true -Dsqoop.thirdparty.lib.dir=<path_to_thirdparty_lib_directory> -Dsqoop.test.mysql.connectstring.host_url=jdbc:mysql://127.0.0.1:3306/ -Dsqoop.test.mysql.databasename=sqoop -Dsqoop.test.mysql.password=Sqoop12345 -Dsqoop.test.mysql.username=sqoop -Dsqoop.test.oracle.connectstring=jdbc:oracle:thin:@//localhost:1521/sqoop -Dsqoop.test.oracle.username=SYSTEM -Dsqoop.test.oracle.password=Sqoop12345 -Dsqoop.test.postgresql.connectstring.host_url=jdbc:postgresql://localhost/ -Dsqoop.test.postgresql.database=sqoop -Dsqoop.test.postgresql.username=sqoop -Dsqoop.test.postgresql.password=Sqoop12345 -Dsqoop.test.cubrid.connectstring.host_url=jdbc:cubrid:localhost:33000 -Dsqoop.test.cubrid.connectstring.username=sqoop -Dsqoop.test.cubrid.connectstring.database=sqoop -Dsqoop.test.cubrid.connectstring.password=Sqoop12345 -Dmapred.child.java.opts="\-Djava.security.egd=file:/dev/../dev/urandom" -Dtest.timeout=10000000 -Dsqoop.test.sqlserver.connectstring.host_url=jdbc:sqlserver://localhost:1433 -Dsqoop.test.sqlserver.database=master -Dms.sqlserver.username=sa -Dms.sqlserver.password=Sqoop12345 -Dsqoop.test.db2.connectstring.host_url=jdbc:db2://localhost:50000 -Dsqoop.test.db2.connectstring.database=SQOOP -Dsqoop.test.db2.connectstring.username=DB2INST1 -Dsqoop.test.db2.connectstring.password=Sqoop12345
----
Please note that even if you do not need to install RDBMSs to run Sqoop third party tests against the Docker containers you still need to install the following tools:
* mysqldump
* mysqlimport
* psql
== Code Quality Analysis
We have three tools which can be used to analyze Sqoop's code quality.
=== Findbugs
Findbugs detects common errors in programming. New patches should not
trigger additional warnings in Findbugs.
Install findbugs (1.3.9) according to its instructions. To use it,
run:
++++
ant findbugs -Dfindbugs.home=/path/to/findbugs/
++++
A report will be generated in +build/findbugs/+
=== Cobertura
Cobertura runs code coverage checks. It instruments the build and
checks that each line and conditional expression is evaluated along
all possible paths.
Install Cobertura according to its instructions. Then run a test with:
++++
ant clean
ant cobertura -Dcobertura.home=/path/to/cobertura
ant cobertura -Dcobertura.home=/path/to/cobertura \
-Dthirdparty=true -Dsqoop.thirdparty.lib.dir=/path/to/thirdparty
++++
(You'll need to run the cobertura target twice; once against the regular
test targets, and once against the thirdparty targets.)
When complete, the report will be placed in +build/cobertura/+
New patches should come with sufficient tests for their functionality
as well as their error recovery code paths. Cobertura can help assess
whether your tests are thorough enough, or where gaps lie.
=== Checkstyle
Checkstyle enforces our style guide. There are currently a very small
number of violations of this style in the source code, but hopefully this
will remain the case. New code should not trigger additional checkstyle
warnings.
Checkstyle does not need to be installed manually; it will be retrieved via
Ivy when necessary.
To run checkstyle, execute:
++++
ant checkstyle
++++
A report will be generated as +build/checkstyle-errors.html+
== Deploying to Maven
To use Sqoop as a dependency in other projects, you can pull Sqoop into your
dependency management system through Maven.
To install Sqoop in your local +.m2+ cache, run:
++++
ant mvn-install
++++
This will install a pom and the Sqoop jar.
To deploy Sqoop to a public repository, use:
++++
ant mvn-deploy
++++
By default, this deploys to repository.cloudera.com. You can choose
the complete URL to deploy to with the +mvn.deploy.url+ property.
By default, this deploys to the "snapshots" repository. To deploy to
"staging" or "releases" on repository.cloudera.com, set the
+mvn.repo+ property accordingly.
== Releasing Sqoop
To build a full release of Sqoop, run +ant release -Dversion=(somever)+.
This will build a binary release tarball and the web-based documentation
as well as run a release audit which flags any source files which may
be missing license headers.
(The release audit can be run standalone with the +ant releaseaudit+
target.)
You must set the +version+ property explicitly; you cannot release a
snapshot. To simultaneously deploy this to a maven repository, include
the +mvn-install+ or +mvn-deploy+ targets as well.
== Using Eclipse
Running +ant eclipse+ will generate +.project+ and +.classpath+ files that
will allow you to edit Sqoop sources in Eclipse with all the library
dependencies correctly resolved. To compile the jars, you should still
use ant.
== Using a specific version of Hadoop
Now Sqoop defaults to use Hadoop 0.23 available from Apache maven repository.
To switch back to the previous version of Hadoop 0.20, for example, run:
++++
ant test -Dhadoopversion=20
++++