-
Notifications
You must be signed in to change notification settings - Fork 2
Install from sources
The code is distributed according to the Maven's Standard Directory Layout. This allows developers (Specifically Java developers) to identify where each component is stored following the 'Convention over Configuration' pattern.
These instructions describe how to install the utility from the source code.
First, you have to retrieve the code from GitHub:
- Via a Clone in Desktop (zip file download).
- Via a
git clone https://github.com/angoca/log4db2
. - If you are using an IDE like Eclipse, you can use the Git plugin (egit) and put the previous URL.
Once the sources are in the computer, there are many different ways to work with and build a release.
If you have Maven, you can build the project and execute the scripts from there:
cd log4db2
mvn
cd target/log4db2/log4db2
If you use Eclipse or DataStudio you can import the sources in an Eclipse project (Java perspective). You have to include the source directory as build path (src/main/sql-pl
, src/main/scripts
, src/test/sql-pl
, src/test/scripts
) and then go to the bin
directory in the shell to execute them.
If you have M2 (Maven plugin) in Eclipse, then configure the project by importing a Maven project. Finally, you only need to go to your bin directory to use the scripts.
If you do not have any of those tools, you have to change to the src/test/scripts
directory.
Once you have decided on a way to use the sources, 3 variables need to be defined in order to run the install, example, and test scripts.
LOG4DB2_SRC_MAIN_CODE_PATH
LOG4DB2_SRC_MAIN_SCRIPT_PATH
LOG4DB2_SRC_TEST_CODE_PATH
LOG4DB2_SRC_TEST_SCRIPT_PATH
These variables are initialized via the init-dev
script. However, they are always set based on the LOG4DB2_PATH
variable according to the current location, thus you have to change the current directory where the tests scripts are stored.
Before installing the scripts in a database, a connection to it has to be established. Otherwise, an error will be raised.
cd src/test/scripts
. ./init-dev
. ../../main/scripts/install
Make sure to put the dot before the command. This will 'source' the values and use the current connection.
cd src\test\scripts
init-dev.bat
..\..\main\scripts\install.bat
cd src\test\scripts
.\init-dev.ps1
..\..\main\scripts\install.ps1
After the installation, all statements should have been successful.
Once you have installed the utility, you can execute tests to verify the code.
In order to run the tests, it is necessary to have installed db2unit
: https://github.com/angoca/db2unit/
This is the table of requirements:
log4db2 | db2unit |
---|---|
Version 1RC (2022-06-08) | Version 2-Beta (2020) |
Version 1B (2014-04-21) | Version 1B (2014-07-26) |
Version 1A (2014-02-15) | - |
You just need to call the allTests
(with the corresponding extension for your environment.)
. ./allTest -- Linux
allTest -- Windows
.\allTest -- Windows PowerShell
Once execute, it will call every single test suite and you can see the output. You have to press enter between calls.
If you want to run one specific test suite, you use the test
script
. ./test ../sql-pl/TestLogs.sql -- Linux
test ..\sql-pl\TestLogs.sql -- Windows
.\test ..\sql-pl\TestLogs.sql -- Windows PowerShell
There is the -np
option that omits the pauses between each set of tests. This option also gives a summary of the execution time. Here some results from different environments:
148 seconds DB2 11.5 FP 7 Docker community MacOSX Catalina 64 bits
MacBook Pro i7 Quad Prod 16 GB SSD disk
14-16 seconds DB2 10.1 FP 0 Express-c MacOSX Mavericks 64 bits
MacBook Pro i7 Quad Prod 16 GB SSD disk
26 seconds DB2 10.1 FP 2 Express-c Ubuntu Precise 12.04 64 bits
Virtual 1 CPU 4 GB hosted on previous MAC
29 seconds DB2 10.1 FP 2 Enterprise trial Suse Enterprise 11 64 bits
Virtual 1 CPU 4 GB hosted on previous MAC
45-59 seconds DB2 9.7 Workgroup Ubuntu Precise 12.04 64 bits
Virtual 2 CPU Xeon 7.5 GB hosted on Amazon AWS m1.large
1m38 seconds DB2 9.7 Workgroup Linux Red Hat 6.4 Santiago
Virtual 1 CPU 64 GB hosted on VMware
2m10 seconds DB2 10.5 Express-c Windows 7
AcerOne C-50 1.00 GHz 2 GB
If you want to check how does it work, you can check the Travis-CI execution output.
In a similar way to the tests, you can execute the examples. For more information, please visit the Running examples section.