Add automated regression tests.

Those tests currently only work when a single table is the target of the
load, and when this target is explicit in the INTO target clause. More
work needs to be done to cover interesting cases like MySQL and SQLite
where we want to diff a full database rather than a single table.
This commit is contained in:
Dimitri Fontaine 2014-06-03 12:19:23 +02:00
parent ae2f7e9ed0
commit 3bcd236de6
18 changed files with 579 additions and 0 deletions

View File

@ -4,9 +4,28 @@ OUT = $(TESTS:.load=.out)
REMOTE = archive.load bossa-all.load bossa.load census-places.load dbf-zip.load
LOCAL = $(filter-out $(REMOTE:.load=.out),$(OUT))
REGRESS= allcols.load \
csv-before-after.load \
csv-districts.load \
csv-error.load \
csv-keep-extra-blanks.load \
csv-trim-extra-blanks.load \
csv.load \
errors.load \
fixed.load \
overflow.load \
partial.load \
serial.load \
udc.load \
xzero.load
PGLOADER ?= ../build/bin/pgloader
regress: clean-out $(addprefix regress/out/, $(REGRESS:.load=.out)) ;
clean-out:
rm -f regress/out/*
local: prepare $(LOCAL)
remote: prepare $(REMOTE:.load=.out)
@ -58,3 +77,7 @@ csv-districts-stdin.out: csv-districts-stdin.load
%.out: %.load
$(PGLOADER) $<
@echo
# Regression tests
regress/out/%.out: %.load
./regress.sh $(PGLOADER) $<

14
test/overflow.load Normal file
View File

@ -0,0 +1,14 @@
LOAD CSV
FROM INLINE with encoding 'ascii'
INTO postgresql:///pgloader?overflow
WITH truncate,
fields terminated by ',',
fields not enclosed
BEFORE LOAD DO
$$ drop table if exists overflow; $$,
$$ CREATE TABLE overflow (id int, f1 text not null) $$;
18446744073709551596,a
12,

19
test/regress.sh Executable file
View File

@ -0,0 +1,19 @@
#! /bin/bash
# regress test driver
# - run pgloader on the given .load command file
# - parse the PostgreSQL connection string and target table
# - output a CSV for the target table
# - diff the CSV and error if diffs found
pgloader=$1
command=$2
targetdb=`awk -F '[ ?]+' '/^ *INTO|into/ {print $3}' < $command`
table=`awk -F '[ ?]+' '/^ *INTO|into/ {print $4}' < $command`
expected=regress/expected/`basename $2 .load`.out
out=regress/out/`basename $2 .load`.out
$pgloader $command
psql -c "copy $table to stdout" -d "$targetdb" > $out
diff -c $expected $out

View File

@ -0,0 +1,8 @@
1 2008-02-18 first entry
2 2008-02-19 second one
3 2008-02-20 another
4 2008-02-21 still running
5 2008-02-22 well, some more
6 2008-02-23 antepenultima
7 2008-02-24 next to last
8 2008-02-25 hey, it's today!

View File

@ -0,0 +1,460 @@
223.207.65.0/24 195756
223.207.66.0-223.207.69.255 209
223.207.70.0/23 29727
223.207.72.0-223.207.74.255 209
223.207.75.0/24 29727
223.207.76.0/25 209
223.207.76.128/25 29727
223.207.77.0-223.207.81.255 209
223.207.82.0/24 107738
223.207.83.0-223.207.89.255 209
223.207.90.0/24 152101
223.207.91.0/24 22537
223.207.92.0/24 152101
223.207.93.0-223.207.95.255 209
223.207.96.0/24 22537
223.207.97.0-223.207.101.255 209
223.207.102.0/24 258257
223.207.103.0-223.207.112.255 209
223.207.113.0/24 157887
223.207.114.0/23 209
223.207.116.0/24 157887
223.207.117.0/24 36801
223.207.118.0/23 209
223.207.120.0/23 157887
223.207.122.0/24 36801
223.207.123.0/24 209
223.207.124.0/24 36801
223.207.125.0/24 209
223.207.126.0/23 36801
223.207.128.0/24 209
223.207.129.0/24 36801
223.207.130.0-223.207.133.255 209
223.207.134.0/23 36801
223.207.136.0/23 22537
223.207.138.0/23 209
223.207.140.0/24 105970
223.207.141.0-223.207.143.255 209
223.207.144.0/24 195756
223.207.145.0-223.207.147.255 209
223.207.148.0/23 29727
223.207.150.0-223.207.165.255 209
223.207.166.0/24 104087
223.207.167.0-223.207.169.255 209
223.207.170.0/24 111006
223.207.171.0-223.207.175.255 209
223.207.176.0/24 104486
223.207.177.0/24 157991
223.207.178.0/24 104486
223.207.179.0-223.207.191.255 209
223.207.192.0/23 29727
223.207.194.0-223.207.197.255 209
223.207.198.0/23 29727
223.207.200.0-223.207.219.255 209
223.207.220.0/24 199446
223.207.221.0/24 209
223.207.222.0/24 152101
223.207.223.0-223.207.224.255 209
223.207.225.0/24 108056
223.207.226.0-223.207.255.255 209
223.208.0.0/17 24328
223.208.128.0/17 47667
223.209.0.0-223.209.111.255 24328
223.209.112.0/20 104221
223.209.128.0-223.210.127.255 24328
223.210.128.0/19 104025
223.210.160.0-223.211.127.255 24328
223.211.128.0/18 104025
223.211.192.0/18 24328
223.212.0.0/15 16496
223.214.0.0/15 104129
223.216.0.0-223.216.6.255 14614
223.216.7.0/24 346442
223.216.8.0-223.216.74.255 14614
223.216.75.0/24 113046
223.216.76.0/23 14614
223.216.78.0/24 341794
223.216.79.0-223.216.128.255 14614
223.216.129.0/24 53101
223.216.130.0/24 14614
223.216.131.0/24 113548
223.216.132.0/22 14614
223.216.136.0/24 53101
223.216.137.0-223.216.140.255 14614
223.216.141.0/24 53101
223.216.142.0-223.216.144.255 14614
223.216.145.0/24 336695
223.216.146.0-223.216.252.255 14614
223.216.253.0/24 53101
223.216.254.0-223.217.0.255 14614
223.217.1.0/24 336677
223.217.2.0/24 20630
223.217.3.0-223.217.4.255 14614
223.217.5.0/24 20630
223.217.6.0/24 14614
223.217.7.0/24 336677
223.217.8.0-223.217.14.255 14614
223.217.15.0/24 113245
223.217.16.0/24 112160
223.217.17.0-223.217.20.255 14614
223.217.21.0/24 104325
223.217.22.0-223.217.50.255 14614
223.217.51.0/24 112896
223.217.52.0-223.217.60.255 14614
223.217.61.0/24 106120
223.217.62.0-223.217.96.255 14614
223.217.97.0-223.217.98.255 112608
223.217.99.0-223.217.106.255 14614
223.217.107.0/24 112398
223.217.108.0-223.217.139.255 14614
223.217.140.0/24 336692
223.217.141.0-223.217.147.255 14614
223.217.148.0/23 337936
223.217.150.0-223.217.163.255 14614
223.217.164.0/24 338005
223.217.165.0-223.217.169.255 14614
223.217.170.0/24 337522
223.217.171.0-223.217.183.255 14614
223.217.184.0/24 106418
223.217.185.0-223.217.188.255 14614
223.217.189.0-223.217.190.255 109797
223.217.191.0-223.217.249.255 14614
223.217.250.0/24 57645
223.217.251.0/24 346205
223.217.252.0-223.218.15.255 14614
223.218.16.0/24 111975
223.218.17.0-223.218.26.255 14614
223.218.27.0/24 112589
223.218.28.0-223.218.38.255 14614
223.218.39.0/24 104239
223.218.40.0-223.218.52.255 14614
223.218.53.0/24 41997
223.218.54.0-223.218.67.255 14614
223.218.68.0/24 337505
223.218.69.0-223.218.70.255 14614
223.218.71.0/24 105896
223.218.72.0/24 337505
223.218.73.0-223.218.107.255 14614
223.218.108.0/24 64704
223.218.109.0/24 113229
223.218.110.0-223.218.127.255 14614
223.218.128.0/24 336674
223.218.129.0/24 341516
223.218.130.0/24 14614
223.218.131.0/24 336674
223.218.132.0/22 14614
223.218.136.0/24 21250
223.218.137.0-223.218.139.255 14614
223.218.140.0/24 336674
223.218.141.0-223.218.145.255 14614
223.218.146.0/24 21250
223.218.147.0-223.218.149.255 14614
223.218.150.0/24 21250
223.218.151.0-223.218.155.255 14614
223.218.156.0/24 336674
223.218.157.0-223.218.161.255 14614
223.218.162.0/24 21250
223.218.163.0/24 14614
223.218.164.0/24 21250
223.218.165.0/24 14614
223.218.166.0/24 56483
223.218.167.0-223.218.170.255 14614
223.218.171.0/24 336674
223.218.172.0-223.218.174.255 14614
223.218.175.0/24 31831
223.218.176.0/24 14614
223.218.177.0-223.218.178.255 104232
223.218.179.0/24 14614
223.218.180.0/24 336674
223.218.181.0-223.218.214.255 14614
223.218.215.0/24 109384
223.218.216.0/24 14614
223.218.217.0/24 285672
223.218.218.0-223.219.2.255 14614
223.219.3.0/24 112305
223.219.4.0-223.219.55.255 14614
223.219.56.0/24 416519
223.219.57.0-223.219.74.255 14614
223.219.75.0/24 113121
223.219.76.0-223.219.85.255 14614
223.219.86.0/24 104230
223.219.87.0-223.219.127.255 14614
223.219.128.0/23 337510
223.219.130.0-223.219.133.255 14614
223.219.134.0/24 106419
223.219.135.0-223.219.138.255 14614
223.219.139.0/24 337510
223.219.140.0-223.219.150.255 14614
223.219.151.0/24 337510
223.219.152.0-223.219.178.255 14614
223.219.179.0/24 106417
223.219.180.0-223.219.187.255 14614
223.219.188.0/24 336676
223.219.189.0-223.219.209.255 14614
223.219.210.0/24 113477
223.219.211.0-223.219.236.255 14614
223.219.237.0/24 337495
223.219.238.0-223.219.240.255 14614
223.219.241.0/24 112338
223.219.242.0-223.219.245.255 14614
223.219.246.0/24 337495
223.219.247.0-223.219.249.255 14614
223.219.250.0/24 112214
223.219.251.0-223.219.255.255 14614
223.220.0.0/15 104339
223.222.0.0/16 119
223.223.0.0-223.223.6.255 69710
223.223.7.0-223.223.8.255 336681
223.223.9.0-223.223.21.255 69710
223.223.22.0/24 336681
223.223.23.0-223.223.44.255 69710
223.223.45.0/24 336681
223.223.46.0-223.223.51.255 69710
223.223.52.0/24 336681
223.223.53.0-223.223.73.255 69710
223.223.74.0/24 336681
223.223.75.0-223.223.127.255 69710
223.223.128.0/24 103
223.223.129.0/24 45899
223.223.130.0-223.223.132.255 103
223.223.133.0-223.223.135.255 45899
223.223.136.0/24 103
223.223.137.0-223.223.139.255 45899
223.223.140.0-223.223.142.255 103
223.223.143.0/24 45899
223.223.144.0/24 108155
223.223.145.0/24 45899
223.223.146.0/24 103
223.223.147.0-223.223.149.255 45899
223.223.150.0/24 103
223.223.151.0-223.223.156.255 45899
223.223.157.0-223.223.159.255 103
223.223.160.0/24 112503
223.223.161.0-223.223.167.255 111
223.223.168.0/21 114
223.223.176.0-223.223.207.255 49
223.223.208.0/22 111
223.223.212.0/24 342351
223.223.213.0-223.223.215.255 111
223.223.216.0/22 94
223.223.220.0/22 191
223.223.224.0/19 111
223.224.0.0-223.224.13.255 103
223.224.14.0/24 127
223.224.15.0-223.224.38.255 103
223.224.39.0/24 348867
223.224.40.0/22 103
223.224.44.0/24 368477
223.224.45.0-223.224.57.255 103
223.224.58.0/24 45899
223.224.59.0-223.224.64.0 103
223.224.64.1-223.224.127.254 20067
223.224.127.255-223.224.128.0 103
223.224.128.1-223.224.255.254 20067
223.224.255.255 103
223.225.0.0-223.225.74.255 108155
223.225.75.0/24 402895
223.225.76.0-223.225.83.255 108155
223.225.84.0/24 70072
223.225.85.0-223.225.255.254 108155
223.225.255.255 103
223.226.0.0/23 105450
223.226.2.0/23 25833
223.226.4.0-223.226.68.255 105450
223.226.69.0/24 24852
223.226.70.0-223.226.88.255 105450
223.226.89.0/24 25938
223.226.90.0-223.226.92.255 105450
223.226.93.0/24 24852
223.226.94.0-223.226.104.255 105450
223.226.105.0/24 45896
223.226.106.0-223.226.126.255 105450
223.226.127.0/24 25938
223.226.128.0-223.226.255.254 105450
223.226.255.255 103
223.227.0.0-223.227.228.255 108155
223.227.229.0/24 20067
223.227.230.0-223.227.232.255 108155
223.227.233.0/24 125023
223.227.234.0-223.227.255.254 108155
223.227.255.255 103
223.228.0.0-223.228.88.255 322866
223.228.89.0/24 20067
223.228.90.0-223.228.247.255 322866
223.228.248.0/23 20067
223.228.250.0-223.228.255.254 322866
223.228.255.255 103
223.229.0.0-223.229.255.254 322866
223.229.255.255 103
223.230.0.0-223.230.10.255 105450
223.230.11.0/24 114830
223.230.12.0-223.230.26.255 105450
223.230.27.0/24 107341
223.230.28.0-223.230.118.255 105450
223.230.119.0/24 187304
223.230.120.0-223.230.255.254 105450
223.230.255.255 103
223.231.0.0-223.231.62.255 108155
223.231.63.0/24 45899
223.231.64.0-223.231.142.255 108155
223.231.143.0/24 30619
223.231.144.0-223.231.161.255 108155
223.231.162.0/24 30619
223.231.163.0-223.231.255.254 108155
223.231.255.255 103
223.232.0.0-223.232.12.255 20067
223.232.13.0/24 32723
223.232.14.0-223.232.24.255 20067
223.232.25.0/24 114830
223.232.26.0-223.232.36.255 20067
223.232.37.0/24 114830
223.232.38.0-223.232.61.255 20067
223.232.62.0/24 114830
223.232.63.0-223.232.70.255 20067
223.232.71.0/24 114830
223.232.72.0-223.232.77.255 20067
223.232.78.0/24 202074
223.232.79.0-223.232.83.255 20067
223.232.84.0/24 114830
223.232.85.0-223.232.112.255 20067
223.232.113.0/24 114830
223.232.114.0-223.232.117.255 20067
223.232.118.0/24 62392
223.232.119.0-223.232.138.255 20067
223.232.139.0/24 32723
223.232.140.0-223.232.255.254 20067
223.232.255.255 103
223.233.0.0-223.233.75.255 105450
223.233.76.0/24 30619
223.233.77.0-223.233.255.254 105450
223.233.255.255 103
223.234.0.0-223.234.28.255 20067
223.234.29.0/24 30619
223.234.30.0-223.234.54.255 20067
223.234.55.0/24 30619
223.234.56.0-223.234.65.255 20067
223.234.66.0/24 30619
223.234.67.0-223.234.90.255 20067
223.234.91.0-223.234.92.255 30619
223.234.93.0-223.234.165.255 20067
223.234.166.0/24 30619
223.234.167.0-223.234.202.255 20067
223.234.203.0/24 109805
223.234.204.0-223.234.237.255 20067
223.234.238.0/24 30619
223.234.239.0-223.234.255.254 20067
223.234.255.255 103
223.235.0.0-223.235.55.255 108155
223.235.56.0/24 30619
223.235.57.0-223.235.126.255 108155
223.235.127.0/24 106037
223.235.128.0-223.235.189.255 108155
223.235.190.0/24 30619
223.235.191.0/24 108155
223.235.192.0/24 109350
223.235.193.0-223.235.235.255 108155
223.235.236.0/24 30619
223.235.237.0-223.235.255.254 108155
223.235.255.255 103
223.236.0.0-223.236.189.255 108155
223.236.190.0/24 30619
223.236.191.0-223.236.204.255 108155
223.236.205.0/24 30619
223.236.206.0-223.236.255.254 108155
223.236.255.255 103
223.237.0.0-223.237.255.254 20067
223.237.255.255 103
223.238.0.0-223.238.16.255 105450
223.238.17.0/24 20067
223.238.18.0-223.238.35.255 105450
223.238.36.0/24 20067
223.238.37.0-223.238.56.255 105450
223.238.57.0/24 20067
223.238.58.0-223.238.82.255 105450
223.238.83.0/24 20067
223.238.84.0-223.238.106.255 105450
223.238.107.0/24 20067
223.238.108.0-223.238.131.255 105450
223.238.132.0/24 20067
223.238.133.0-223.238.154.255 105450
223.238.155.0/24 20067
223.238.156.0-223.238.169.255 105450
223.238.170.0/24 20067
223.238.171.0-223.238.230.255 105450
223.238.231.0/24 20067
223.238.232.0/22 105450
223.238.236.0/24 20067
223.238.237.0-223.238.255.254 105450
223.238.255.255 103
223.239.0.0-223.239.159.255 20067
223.239.160.0/20 45899
223.239.176.0-223.239.194.255 20067
223.239.195.0/24 22962
223.239.196.0/24 20067
223.239.197.0-223.239.198.255 22962
223.239.199.0-223.239.255.254 20067
223.239.255.255 103
223.240.0.0/13 104129
223.248.0.0/14 14431
223.252.0.0/17 11716
223.252.128.0/19 24328
223.252.160.0/19 49
223.252.192.0/19 47667
223.252.224.0/19 14431
223.253.0.0/16 22883
223.254.0.0/16 103995
223.255.0.0/17 24328
223.255.128.0/24 35428
223.255.129.0/24 25389
223.255.130.0/24 35428
223.255.131.0/24 14416
223.255.132.0-223.255.136.255 35428
223.255.137.0/24 14416
223.255.138.0-223.255.140.255 35428
223.255.141.0/24 104037
223.255.142.0/23 35428
223.255.144.0/24 14416
223.255.145.0/24 35428
223.255.146.0/25 21240
223.255.146.128/25 14416
223.255.147.0/24 35428
223.255.148.0/24 21240
223.255.149.0-223.255.150.255 35428
223.255.151.0-223.255.152.255 14416
223.255.153.0-223.255.157.255 35428
223.255.158.0/23 14416
223.255.160.0/24 35428
223.255.161.0/24 14416
223.255.162.0-223.255.167.255 35428
223.255.168.0/23 21240
223.255.170.0/24 35428
223.255.171.0/24 14416
223.255.172.0-223.255.187.255 35428
223.255.188.0/24 14416
223.255.189.0/24 35428
223.255.190.0/25 14416
223.255.190.128/25 21240
223.255.191.0/24 35428
223.255.192.0/19 22883
223.255.224.0/27 32979
223.255.224.32-223.255.225.255 206376
223.255.226.0/24 104200
223.255.227.0-223.255.229.31 206376
223.255.229.32/27 47976
223.255.229.64/28 206376
223.255.229.80-223.255.229.255 47976
223.255.230.0/24 206376
223.255.231.0/27 105611
223.255.231.32/27 337502
223.255.231.64/26 206376
223.255.231.128/27 36834
223.255.231.160-223.255.231.255 206376
223.255.232.0/22 17
223.255.236.0/22 49
223.255.240.0/22 94
223.255.244.0/23 108612
223.255.246.0/23 103
223.255.248.0/22 17
223.255.252.0/23 49
223.255.254.0/24 191
223.255.255.0/24 17

View File

View File

@ -0,0 +1,3 @@
BORDET Jordane
BORDET Audrey
LASTNAME "opening quote

View File

@ -0,0 +1,6 @@
1 quoted empty string should be empty string
2 no value between separators \N should be null
3 quoted blanks should be blanks
4 unquoted blanks should be null
5 unquoted string no quote should be 'no quote'
6 quoted separator a,b,c should be 'a,b,c'

View File

@ -0,0 +1,7 @@
1 quoted empty string should be empty string
2 no value between separators \N should be null
3 quoted blanks should be blanks
4 unquoted blanks \N should be null
5 unquoted string no quote should be 'no quote'
6 quoted separator a,b,c should be 'a,b,c'
7 trim extra blanks test string should be 'test string'

View File

@ -0,0 +1,6 @@
33996344 33996351 GB United Kingdom
50331648 68257567 US United States
68257568 68257599 CA Canada
68257600 68259583 US United States
68259584 68259599 CA Canada
68259600 68296775 US United States

View File

View File

@ -0,0 +1,3 @@
123456789 2008-05-20 11:43:12.5 firstline
123456 2008-05-21 15:18:23 left blank-padded
1234567890 2008-05-22 08:23:15.6 another line

View File

View File

@ -0,0 +1,7 @@
1 foo bar \N hop
2 foo bar \N hop
3 foo bar \N hop
4 foo bar \N hop
5 foo bar \N hop
6 foo bar \N hop
7 foo bar \N hop

View File

@ -0,0 +1,7 @@
1 2006-11-11 some first row text
2 2006-11-11 some second row text
3 2006-10-12 some third row text
4 2006-10-04 \\
5 2006-05-12 some fifth row text
6 2006-07-10 some sixth row text
7 \N some null date to play with

View File

@ -0,0 +1,5 @@
5 constant value 1
10 constant value 2
4 constant value 3
18 constant value 4
2 constant value 5

View File

@ -0,0 +1,7 @@
1 2006-11-11 some first row text
2 2006-11-13 some second row text
3 2006-10-12 some third row text
4 2006-10-04 \\
5 2006-05-12 some fifth row text
6 2006-07-10 some sixth row text
7 \N some null date to play with

4
test/regress/out/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore