infobright-loader 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +19 -0
- data/LICENSE-2.0.txt +202 -0
- data/README.md +232 -0
- data/Rakefile +2 -0
- data/bin/infobright-loader +45 -0
- data/control-file/template.yml +23 -0
- data/infobright-loader.gemspec +35 -0
- data/lib/infobright-loader.rb +5 -0
- data/lib/infobright-loader/cli/config.rb +204 -0
- data/lib/infobright-loader/cli/loader.rb +66 -0
- data/lib/infobright-loader/db.rb +90 -0
- data/lib/infobright-loader/loader.rb +175 -0
- data/lib/infobright-loader/version.rb +4 -0
- data/tests/manual/bad-files/.gitignore +1 -0
- data/tests/manual/bad-files/control-file-raw.yml +50 -0
- data/tests/manual/bad-files/data/b/b_1.txt +6 -0
- data/tests/manual/bad-files/data/b/b_2.txt +6 -0
- data/tests/manual/bad-files/data/b/b_3.txt +6 -0
- data/tests/manual/bad-files/data/b/b_4.txt +6 -0
- data/tests/manual/bad-files/data/b/b_5.txt +6 -0
- data/tests/manual/bad-files/data/b/b_6.txt +6 -0
- data/tests/manual/bad-files/data/c/c_1.txt +6 -0
- data/tests/manual/bad-files/data/c/c_2.txt +6 -0
- data/tests/manual/bad-files/data/c/c_3.txt +6 -0
- data/tests/manual/bad-files/data/c/c_4.txt +6 -0
- data/tests/manual/bad-files/data/c/c_5.txt +6 -0
- data/tests/manual/bad-files/data/c/c_6.txt +6 -0
- data/tests/manual/bad-files/data/d/d_1.txt +6 -0
- data/tests/manual/bad-files/data/d/d_2.txt +6 -0
- data/tests/manual/bad-files/data/d/d_3.txt +6 -0
- data/tests/manual/bad-files/data/d/d_4.txt +6 -0
- data/tests/manual/bad-files/data/d/d_5.txt +6 -0
- data/tests/manual/bad-files/data/d/d_6.txt +6 -0
- data/tests/manual/bad-files/data/e/e_1.txt +6 -0
- data/tests/manual/bad-files/data/e/e_2.txt +6 -0
- data/tests/manual/bad-files/data/e/e_3.txt +6 -0
- data/tests/manual/bad-files/data/e/e_4.txt +6 -0
- data/tests/manual/bad-files/data/e/e_5.txt +6 -0
- data/tests/manual/bad-files/data/e/e_6.txt +6 -0
- data/tests/manual/bad-files/data/f/f_1.txt +6 -0
- data/tests/manual/bad-files/data/f/f_2.txt +6 -0
- data/tests/manual/bad-files/data/f/f_3.txt +6 -0
- data/tests/manual/bad-files/data/f/f_4.txt +6 -0
- data/tests/manual/bad-files/data/f/f_5.txt +6 -0
- data/tests/manual/bad-files/data/f/f_6.txt +6 -0
- data/tests/manual/bad-files/run_test.sh +40 -0
- data/tests/manual/bad-files/setup.sql +8 -0
- data/tests/manual/bad-files/verify.sql +10 -0
- data/tests/manual/control-file/.gitignore +1 -0
- data/tests/manual/control-file/control-file-raw.yml +50 -0
- data/tests/manual/control-file/data/b/b_1.txt +6 -0
- data/tests/manual/control-file/data/b/b_2.txt +6 -0
- data/tests/manual/control-file/data/b/b_3.txt +6 -0
- data/tests/manual/control-file/data/b/b_4.txt +6 -0
- data/tests/manual/control-file/data/b/b_5.txt +6 -0
- data/tests/manual/control-file/data/b/b_6.txt +6 -0
- data/tests/manual/control-file/data/c/c_1.txt +6 -0
- data/tests/manual/control-file/data/c/c_2.txt +6 -0
- data/tests/manual/control-file/data/c/c_3.txt +6 -0
- data/tests/manual/control-file/data/c/c_4.txt +6 -0
- data/tests/manual/control-file/data/c/c_5.txt +6 -0
- data/tests/manual/control-file/data/c/c_6.txt +6 -0
- data/tests/manual/control-file/data/d/d_1.txt +6 -0
- data/tests/manual/control-file/data/d/d_2.txt +6 -0
- data/tests/manual/control-file/data/d/d_3.txt +6 -0
- data/tests/manual/control-file/data/d/d_4.txt +6 -0
- data/tests/manual/control-file/data/d/d_5.txt +6 -0
- data/tests/manual/control-file/data/d/d_6.txt +6 -0
- data/tests/manual/control-file/data/e/e_1.txt +6 -0
- data/tests/manual/control-file/data/e/e_2.txt +6 -0
- data/tests/manual/control-file/data/e/e_3.txt +6 -0
- data/tests/manual/control-file/data/e/e_4.txt +6 -0
- data/tests/manual/control-file/data/e/e_5.txt +6 -0
- data/tests/manual/control-file/data/e/e_6.txt +6 -0
- data/tests/manual/control-file/data/f/f_1.txt +6 -0
- data/tests/manual/control-file/data/f/f_2.txt +6 -0
- data/tests/manual/control-file/data/f/f_3.txt +6 -0
- data/tests/manual/control-file/data/f/f_4.txt +6 -0
- data/tests/manual/control-file/data/f/f_5.txt +6 -0
- data/tests/manual/control-file/data/f/f_6.txt +6 -0
- data/tests/manual/control-file/run_test.sh +40 -0
- data/tests/manual/control-file/setup.sql +8 -0
- data/tests/manual/control-file/verify.sql +10 -0
- data/tests/manual/folder/data/a/a_1.txt +6 -0
- data/tests/manual/folder/data/a/a_2.txt +6 -0
- data/tests/manual/folder/data/a/a_3.txt +6 -0
- data/tests/manual/folder/data/a/a_4.txt +6 -0
- data/tests/manual/folder/data/a/a_5.txt +6 -0
- data/tests/manual/folder/data/a/a_6.txt +6 -0
- data/tests/manual/folder/run_test.sh +37 -0
- data/tests/manual/folder/setup.sql +4 -0
- data/tests/manual/folder/verify.sql +2 -0
- metadata +158 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Copyright (c) 2012 SnowPlow Analytics Ltd. All rights reserved.
|
3
|
+
#
|
4
|
+
# This program is licensed to you under the Apache License Version 2.0,
|
5
|
+
# and you may not use this file except in compliance with the Apache License Version 2.0.
|
6
|
+
# You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing,
|
9
|
+
# software distributed under the Apache License Version 2.0 is distributed on an
|
10
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
12
|
+
|
13
|
+
# Author:: Alex Dean (mailto:support@snowplowanalytics.com)
|
14
|
+
# Copyright:: Copyright (c) 2012 SnowPlow Analytics Ltd
|
15
|
+
# License:: Apache License Version 2.0
|
16
|
+
|
17
|
+
# input parameters
|
18
|
+
if [ $# != 2 ]; then
|
19
|
+
echo; echo 'syntax: '$0' <username> <password>'; echo
|
20
|
+
exit 1
|
21
|
+
else
|
22
|
+
# assign parameters
|
23
|
+
USERNAME=$1
|
24
|
+
PASSWORD=$2
|
25
|
+
fi
|
26
|
+
|
27
|
+
echo "Running folder-based test..."
|
28
|
+
SQL=`locate mysql-ib`
|
29
|
+
PWD=`pwd`
|
30
|
+
|
31
|
+
echo "Setting up Infobright"
|
32
|
+
cat setup.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
|
33
|
+
|
34
|
+
echo "Running Infobright Ruby Loader in control file mode"
|
35
|
+
sed "s|<<USERNAME>>|$USERNAME|;s|<<PASSWORD>>|$PASSWORD|;s|<<PATH>>|$PWD|" ./control-file-raw.yml > ./control-file-out.yml
|
36
|
+
bundle exec infobright-loader -c control-file-out.yml -d irl_tests -e \" # Override a couple of args to test that too
|
37
|
+
rm ./control-file-out.yml
|
38
|
+
|
39
|
+
echo "Verifying the load into Infobright - please visually inspect:"
|
40
|
+
cat verify.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
drop database if exists irl_tests;
|
2
|
+
create database irl_tests;
|
3
|
+
use irl_tests;
|
4
|
+
create table b (id int, description varchar(255)) engine=brighthouse;
|
5
|
+
create table c (id int, description varchar(255)) engine=brighthouse;
|
6
|
+
create table d (id int, description varchar(255)) engine=brighthouse;
|
7
|
+
create table e (id int, description varchar(255)) engine=brighthouse;
|
8
|
+
create table f (id int, description varchar(255)) engine=brighthouse;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
use irl_tests;
|
2
|
+
|
3
|
+
-- We should be able to make a nice table joining up all the rows in each table
|
4
|
+
select b.id as row, b.description as b_desc, c.description as c_desc, d.description as d_desc, e.description as e_desc, f.description as f_desc
|
5
|
+
from b
|
6
|
+
left join c on b.id = c.id
|
7
|
+
left join d on b.id = d.id
|
8
|
+
left join e on b.id = e.id
|
9
|
+
left join f on b.id = f.id
|
10
|
+
order by b.id;
|
@@ -0,0 +1 @@
|
|
1
|
+
control-file-out.yml
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Control file for Infobright Ruby Loader control file test
|
2
|
+
#
|
3
|
+
# Is processed with sed to finalise <<x>> variables before
|
4
|
+
# the test is run
|
5
|
+
|
6
|
+
:load:
|
7
|
+
:processes: 3 # Test with 3 processes populating 5 tables
|
8
|
+
:database:
|
9
|
+
:name: wrong # Will override at the command line to irl_tests
|
10
|
+
:username: <<USERNAME>>
|
11
|
+
:password: <<PASSWORD>>
|
12
|
+
:data_format:
|
13
|
+
:separator: \|
|
14
|
+
:encloser: \' # Will override at the command line to "
|
15
|
+
:data_loads:
|
16
|
+
b:
|
17
|
+
- <<PATH>>/data/b/b_1.txt
|
18
|
+
- <<PATH>>/data/b/b_2.txt
|
19
|
+
- <<PATH>>/data/b/b_3.txt
|
20
|
+
- <<PATH>>/data/b/b_4.txt
|
21
|
+
- <<PATH>>/data/b/b_5.txt
|
22
|
+
- <<PATH>>/data/b/b_6.txt
|
23
|
+
c:
|
24
|
+
- <<PATH>>/data/c/c_1.txt
|
25
|
+
- <<PATH>>/data/c/c_2.txt
|
26
|
+
- <<PATH>>/data/c/c_3.txt
|
27
|
+
- <<PATH>>/data/c/c_4.txt
|
28
|
+
- <<PATH>>/data/c/c_5.txt
|
29
|
+
- <<PATH>>/data/c/c_6.txt
|
30
|
+
d:
|
31
|
+
- <<PATH>>/data/d/d_1.txt
|
32
|
+
- <<PATH>>/data/d/d_2.txt
|
33
|
+
- <<PATH>>/data/d/d_3.txt
|
34
|
+
- <<PATH>>/data/d/d_4.txt
|
35
|
+
- <<PATH>>/data/d/d_5.txt
|
36
|
+
- <<PATH>>/data/d/d_6.txt
|
37
|
+
e:
|
38
|
+
- <<PATH>>/data/e/e_1.txt
|
39
|
+
- <<PATH>>/data/e/e_2.txt
|
40
|
+
- <<PATH>>/data/e/e_3.txt
|
41
|
+
- <<PATH>>/data/e/e_4.txt
|
42
|
+
- <<PATH>>/data/e/e_5.txt
|
43
|
+
- <<PATH>>/data/e/e_6.txt
|
44
|
+
f:
|
45
|
+
- <<PATH>>/data/f/f_1.txt
|
46
|
+
- <<PATH>>/data/f/f_2.txt
|
47
|
+
- <<PATH>>/data/f/f_3.txt
|
48
|
+
- <<PATH>>/data/f/f_4.txt
|
49
|
+
- <<PATH>>/data/f/f_5.txt
|
50
|
+
- <<PATH>>/data/f/f_6.txt
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# Copyright (c) 2012 SnowPlow Analytics Ltd. All rights reserved.
|
3
|
+
#
|
4
|
+
# This program is licensed to you under the Apache License Version 2.0,
|
5
|
+
# and you may not use this file except in compliance with the Apache License Version 2.0.
|
6
|
+
# You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing,
|
9
|
+
# software distributed under the Apache License Version 2.0 is distributed on an
|
10
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
12
|
+
|
13
|
+
# Author:: Alex Dean (mailto:support@snowplowanalytics.com)
|
14
|
+
# Copyright:: Copyright (c) 2012 SnowPlow Analytics Ltd
|
15
|
+
# License:: Apache License Version 2.0
|
16
|
+
|
17
|
+
# input parameters
|
18
|
+
if [ $# != 2 ]; then
|
19
|
+
echo; echo 'syntax: '$0' <username> <password>'; echo
|
20
|
+
exit 1
|
21
|
+
else
|
22
|
+
# assign parameters
|
23
|
+
USERNAME=$1
|
24
|
+
PASSWORD=$2
|
25
|
+
fi
|
26
|
+
|
27
|
+
echo "Running folder-based test..."
|
28
|
+
SQL=`locate mysql-ib`
|
29
|
+
PWD=`pwd`
|
30
|
+
|
31
|
+
echo "Setting up Infobright"
|
32
|
+
cat setup.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
|
33
|
+
|
34
|
+
echo "Running Infobright Ruby Loader in control file mode"
|
35
|
+
sed "s|<<USERNAME>>|$USERNAME|;s|<<PASSWORD>>|$PASSWORD|;s|<<PATH>>|$PWD|" ./control-file-raw.yml > ./control-file-out.yml
|
36
|
+
bundle exec infobright-loader -c control-file-out.yml -d irl_tests -e \" # Override a couple of args to test that too
|
37
|
+
rm ./control-file-out.yml
|
38
|
+
|
39
|
+
echo "Verifying the load into Infobright - please visually inspect:"
|
40
|
+
cat verify.sql | ${SQL} -u ${USERNAME} --password=${PASSWORD}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
drop database if exists irl_tests;
|
2
|
+
create database irl_tests;
|
3
|
+
use irl_tests;
|
4
|
+
create table b (id int, description varchar(255)) engine=brighthouse;
|
5
|
+
create table c (id int, description varchar(255)) engine=brighthouse;
|
6
|
+
create table d (id int, description varchar(255)) engine=brighthouse;
|
7
|
+
create table e (id int, description varchar(255)) engine=brighthouse;
|
8
|
+
create table f (id int, description varchar(255)) engine=brighthouse;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
use irl_tests;
|
2
|
+
|
3
|
+
-- We should be able to make a nice table joining up all the rows in each table
|
4
|
+
select b.id as row, b.description as b_desc, c.description as c_desc, d.description as d_desc, e.description as e_desc, f.description as f_desc
|
5
|
+
from b
|
6
|
+
left join c on b.id = c.id
|
7
|
+
left join d on b.id = d.id
|
8
|
+
left join e on b.id = e.id
|
9
|
+
left join f on b.id = f.id
|
10
|
+
order by b.id;
|