You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by bo...@apache.org on 2017/10/12 15:53:57 UTC

sqoop git commit: SQOOP-3229: Document how to run third party tests manually with databases running in docker

Repository: sqoop
Updated Branches:
  refs/heads/trunk d0770ac6a -> 1c1905b08


SQOOP-3229: Document how to run third party tests manually with databases running in docker

(Szabolcs Vasas via Boglarka Egyed)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/1c1905b0
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/1c1905b0
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/1c1905b0

Branch: refs/heads/trunk
Commit: 1c1905b08f6db456589c1f2f3f8d5a004aed18ee
Parents: d0770ac
Author: Boglarka Egyed <bo...@apache.org>
Authored: Thu Oct 12 17:51:05 2017 +0200
Committer: Boglarka Egyed <bo...@apache.org>
Committed: Thu Oct 12 17:51:05 2017 +0200

----------------------------------------------------------------------
 COMPILING.txt                                   |  96 ++++++++++++++--
 .../docker-compose/db2scripts/db2entrypoint.sh  |  22 ++++
 .../docker-compose/oraclescripts/healthcheck.sh |  19 ++++
 .../oraclescripts/startup/oracleusersetup.sql   |  19 ++++
 .../sqoop-thirdpartytest-db-services.yml        | 113 +++++++++++++++++++
 .../start-thirdpartytest-db-containers.sh       |  20 ++++
 .../stop-thirdpartytest-db-containers.sh        |  20 ++++
 7 files changed, 301 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/COMPILING.txt
----------------------------------------------------------------------
diff --git a/COMPILING.txt b/COMPILING.txt
index eb69b22..f531dd4 100644
--- a/COMPILING.txt
+++ b/COMPILING.txt
@@ -66,9 +66,11 @@ 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, and download the JDBC drivers for each one.
+and configure the databases or run them in Docker containers, and download the JDBC drivers for each one.
 
-=== MySQL
+=== 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
@@ -83,7 +85,7 @@ sqoop.test.mysql.connectstring.host_url=jdbc:mysql://host.example.com/
 If not specified, the default value used for this property is:
 jdbc:mysql://localhost/
 
-=== Oracle
+==== Oracle
 
 Install Oracle Enterprise Edition 10.2.0+. Instructions for configuring the
 database are in OracleManagerTest. Download the ojdbc6_g jar.
@@ -103,7 +105,7 @@ 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
+==== PostgreSQL
 
 Install PostgreSQL 8.3.9. Download the postgresql 8.4 jdbc driver. Instructions
 for configuring the database are in PostgresqlTest.
@@ -117,7 +119,7 @@ sqoop.test.postgresql.connectstring.host_url=jdbc:postgresql://sqoop-dbs.sf.clou
 If not specified, the default value used for this property is:
 jdbc:postgresql://localhost/
 
-=== SQL Server
+==== SQL Server
 
 Install SQL Server Express 2012 and create a database instance and
 download the appropriate JDBC driver. Instructions for configuring the
@@ -135,7 +137,7 @@ 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
+==== 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
@@ -151,7 +153,7 @@ sqoop.test.cubrid.connectstring.host_url=jdbc:cubrid:localhost
 If not specified, the default value used for this property is:
 jdbc:cubrid:localhost
 
-=== DB2
+==== DB2
 
 Install DB2 9.74 Express C and download the appropriate JDBC driver.
 Instructions for configuring the server can be found in
@@ -169,7 +171,7 @@ 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
+==== Running the Third-party Tests
 
 After the third-party databases are installed and configured, run:
 
@@ -188,6 +190,84 @@ 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.

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/src/scripts/thirdpartytest/docker-compose/db2scripts/db2entrypoint.sh
----------------------------------------------------------------------
diff --git a/src/scripts/thirdpartytest/docker-compose/db2scripts/db2entrypoint.sh b/src/scripts/thirdpartytest/docker-compose/db2scripts/db2entrypoint.sh
new file mode 100755
index 0000000..2397ab8
--- /dev/null
+++ b/src/scripts/thirdpartytest/docker-compose/db2scripts/db2entrypoint.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# 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.
+
+set -e
+echo -e "$DB2INST1_PASSWORD\n$DB2INST1_PASSWORD" | passwd db2inst1
+su - db2inst1 -c "db2start;db2 create db SQOOP"
+nohup /usr/sbin/sshd -D 2>&1 > /dev/null &
+while true; do sleep 1000; done

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/src/scripts/thirdpartytest/docker-compose/oraclescripts/healthcheck.sh
----------------------------------------------------------------------
diff --git a/src/scripts/thirdpartytest/docker-compose/oraclescripts/healthcheck.sh b/src/scripts/thirdpartytest/docker-compose/oraclescripts/healthcheck.sh
new file mode 100755
index 0000000..fb7800e
--- /dev/null
+++ b/src/scripts/thirdpartytest/docker-compose/oraclescripts/healthcheck.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# 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.
+
+
+echo "SELECT 1 from DUAL;" | sqlplus -L SQOOPTEST2/ABCDEF@//localhost:1521/sqoop

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/src/scripts/thirdpartytest/docker-compose/oraclescripts/startup/oracleusersetup.sql
----------------------------------------------------------------------
diff --git a/src/scripts/thirdpartytest/docker-compose/oraclescripts/startup/oracleusersetup.sql b/src/scripts/thirdpartytest/docker-compose/oraclescripts/startup/oracleusersetup.sql
new file mode 100644
index 0000000..8ef9f8b
--- /dev/null
+++ b/src/scripts/thirdpartytest/docker-compose/oraclescripts/startup/oracleusersetup.sql
@@ -0,0 +1,19 @@
+-- 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.
+
+ALTER SESSION SET "_ORACLE_SCRIPT"=true;
+CREATE USER SQOOPTEST2 identified by ABCDEF;
+GRANT CONNECT, RESOURCE to SQOOPTEST2;
+ALTER USER SQOOPTEST2 quota unlimited on USERS;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/src/scripts/thirdpartytest/docker-compose/sqoop-thirdpartytest-db-services.yml
----------------------------------------------------------------------
diff --git a/src/scripts/thirdpartytest/docker-compose/sqoop-thirdpartytest-db-services.yml b/src/scripts/thirdpartytest/docker-compose/sqoop-thirdpartytest-db-services.yml
new file mode 100644
index 0000000..2f4a07f
--- /dev/null
+++ b/src/scripts/thirdpartytest/docker-compose/sqoop-thirdpartytest-db-services.yml
@@ -0,0 +1,113 @@
+# 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.
+
+version: '3'
+services:
+  mysql:
+    image: mysql:5.7.19
+    container_name: sqoop_mysql_container
+    environment:
+      COMPOSE_HTTP_TIMEOUT: 200
+      MYSQL_ROOT_PASSWORD: sqoop
+      MYSQL_USER: sqoop
+      MYSQL_PASSWORD: Sqoop12345
+      MYSQL_DATABASE: sqoop
+    ports:
+      - 3306:3306
+    command:
+      mysqld --sql_mode="ANSI_QUOTES"
+    healthcheck:
+      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
+      interval: 30s
+      timeout: 10s
+      retries: 10
+  postgresql:
+    image: postgres:9.6.4
+    container_name: sqoop_postgresql_container
+    environment:
+      COMPOSE_HTTP_TIMEOUT: 200
+      POSTGRES_DB: sqoop
+      POSTGRES_USER: sqoop
+      POSTGRES_PASSWORD: Sqoop12345
+    ports:
+      - 5432:5432
+    healthcheck:
+      test: ["CMD", "pg_isready"]
+      interval: 30s
+      timeout: 10s
+      retries: 10
+  mssql:
+    image: microsoft/mssql-server-linux:2017-GA
+    container_name: sqoop_mssql_container
+    environment:
+      COMPOSE_HTTP_TIMEOUT: 200
+      ACCEPT_EULA: Y
+      SA_PASSWORD: Sqoop12345
+    ports:
+      - 1433:1433
+    healthcheck:
+      test: ["CMD", "/opt/mssql-tools/bin/sqlcmd", "-S", "localhost", "-U", "sa", "-P", "Sqoop12345", "-Q" , "SELECT 1"]
+      interval: 30s
+      timeout: 10s
+      retries: 10
+  cubrid:
+    image: cubrid/cubrid:10.0
+    container_name: sqoop_cubrid_container
+    environment:
+      COMPOSE_HTTP_TIMEOUT: 200
+      CUBRID_DB: sqoop
+      CUBRID_USER: sqoop
+      CUBRID_PASSWORD: Sqoop12345
+    ports:
+      - 33000:33000
+    healthcheck:
+      test: ["CMD", "csql", "sqoop", "-c", "SELECT 1"]
+      interval: 30s
+      timeout: 10s
+      retries: 10
+  oracle:
+    image: oracle/database:12.2.0.1-ee
+    container_name: sqoop_oracle_container
+    environment:
+      COMPOSE_HTTP_TIMEOUT: 200
+      ORACLE_SID: sqoop
+      ORACLE_PWD: Sqoop12345
+    ports:
+      - 1521:1521
+    volumes:
+      - ./oraclescripts:/opt/oracle/scripts
+    healthcheck:
+      test: ["CMD", "/opt/oracle/scripts/healthcheck.sh"]
+      interval: 30s
+      timeout: 10s
+      retries: 60
+  db2:
+    image: ibmcom/db2express-c:10.5.0.5-3.10.0
+    container_name: sqoop_db2_container
+    environment:
+      COMPOSE_HTTP_TIMEOUT: 200
+      DB2INST1_PASSWORD: Sqoop12345
+      LICENSE: accept
+    ports:
+      - 50000:50000
+    volumes:
+      - ./db2scripts:/home/db2inst1/db2scripts
+    entrypoint:
+        /home/db2inst1/db2scripts/db2entrypoint.sh
+    healthcheck:
+      test: ["CMD", "/home/db2inst1/sqllib/bin/db2", "CONNECT", "TO", "SQOOP"]
+      interval: 30s
+      timeout: 10s
+      retries: 20

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/src/scripts/thirdpartytest/start-thirdpartytest-db-containers.sh
----------------------------------------------------------------------
diff --git a/src/scripts/thirdpartytest/start-thirdpartytest-db-containers.sh b/src/scripts/thirdpartytest/start-thirdpartytest-db-containers.sh
new file mode 100755
index 0000000..708d206
--- /dev/null
+++ b/src/scripts/thirdpartytest/start-thirdpartytest-db-containers.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# 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.
+
+BASEDIR=$(dirname "$0")
+
+docker-compose -f $BASEDIR/docker-compose/sqoop-thirdpartytest-db-services.yml up -d "$@"

http://git-wip-us.apache.org/repos/asf/sqoop/blob/1c1905b0/src/scripts/thirdpartytest/stop-thirdpartytest-db-containers.sh
----------------------------------------------------------------------
diff --git a/src/scripts/thirdpartytest/stop-thirdpartytest-db-containers.sh b/src/scripts/thirdpartytest/stop-thirdpartytest-db-containers.sh
new file mode 100755
index 0000000..6833db0
--- /dev/null
+++ b/src/scripts/thirdpartytest/stop-thirdpartytest-db-containers.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# 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.
+
+BASEDIR=$(dirname "$0")
+
+docker-compose -f $BASEDIR/docker-compose/sqoop-thirdpartytest-db-services.yml rm --stop -f