-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_test.sh
executable file
·110 lines (95 loc) · 5.19 KB
/
run_test.sh
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
#!/usr/bin/env bash
# Drop and recreate test databases
echo ""
echo "Drop and recreate test databases"
echo "##########################"
dropdb lizsync_central && dropdb lizsync_clone_a && dropdb lizsync_clone_b
createdb lizsync_central && createdb lizsync_clone_a && createdb lizsync_clone_b
# You then need to create 2 PostgreSQL services: lizsync_central and lizsync_clone_a
# Import test data
echo ""
echo "Import test data"
echo "##########################"
lizsync/test/data/import_test_data_into_postgresql.sh lizsync_central test
# Add trigger which generates a value based on sequence, which must be unique (and will fail if synchronized as is)
# psql service=lizsync_central -f test/data/test_unique_field_based_on_serial_with_trigger.sql
# Run algs to prepare central database
# Install Lizsync tools on the central database
echo ""
echo "Install Lizsync tools on the central database"
echo "##########################"
ALGO="lizsync:create_database_structure"
PARAMS='{"CONNECTION_NAME": "lizsync_central", "OVERRIDE_AUDIT": false, "OVERRIDE_LIZSYNC": false}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
# Prepare central database
echo ""
echo "Prepare central database"
echo "##########################"
ALGO="lizsync:initialize_central_database"
PARAMS='{"CONNECTION_NAME_CENTRAL":"lizsync_central","ADD_SERVER_ID":true,"ADD_UID_COLUMNS":true,"ADD_AUDIT_TRIGGERS":true,"SCHEMAS":"test"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
#psql service=lizsync_central -c "SELECT audit.audit_table('test.pluviometers')"
#psql service=lizsync_central -c "SELECT * FROM audit.logged_relations"
# Create a package from the central database
echo ""
echo "Create a package from the central database"
echo "##########################"
ALGO="lizsync:package_central_database"
PARAMS='{"CONNECTION_NAME_CENTRAL":"lizsync_central","POSTGRESQL_BINARY_PATH":"/usr/bin/","SCHEMAS":"test","ZIP_FILE":"/home/mdouchin/Documents/3liz/Valabre/GeoPoppy/Logiciel/qgis_3liz_fake_ftp_remote_server/test/archives/archive.zip", "ADDITIONAL_SQL_FILE": "/home/mdouchin/Documents/3liz/qgis/QGIS3/plugins/lizsync/test/data/additional_sql_commande.sql"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
# Deploy a database package to the clone
echo ""
echo "Deploy a database package to the clone a"
echo "##########################"
ALGO="lizsync:deploy_database_server_package"
PARAMS='{"CONNECTION_NAME_CENTRAL":"lizsync_central","CONNECTION_NAME_CLONE":"lizsync_clone_a","POSTGRESQL_BINARY_PATH":"/usr/bin/","ZIP_FILE":"/home/mdouchin/Documents/3liz/Valabre/GeoPoppy/Logiciel/qgis_3liz_fake_ftp_remote_server/test/archives/archive.zip"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
echo ""
echo "Deploy a database package to the clone b"
echo "##########################"
ALGO="lizsync:deploy_database_server_package"
PARAMS='{"CONNECTION_NAME_CENTRAL":"lizsync_central","CONNECTION_NAME_CLONE":"lizsync_clone_b","POSTGRESQL_BINARY_PATH":"/usr/bin/","ZIP_FILE":"/home/mdouchin/Documents/3liz/Valabre/GeoPoppy/Logiciel/qgis_3liz_fake_ftp_remote_server/test/archives/archive.zip"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
exit
# Edit data in both databases
echo ""
echo "Edit data in both databases"
echo "##########################"
# Two SQL scripts are provided, which you can adapt beforehand:
psql service=lizsync_central -f lizsync/test/data/central_database_edition_sample.sql
sleep 2
psql service=lizsync_clone_a -f lizsync/test/data/clone_a_database_edition_sample.sql
sleep 2
psql service=lizsync_clone_b -f lizsync/test/data/clone_b_database_edition_sample.sql
#exit
# Run Two-way database synchronization
echo ""
echo "Run Two-way database synchronization"
echo "##########################"
ALGO="lizsync:synchronize_database"
PARAMS='{"CONNECTION_NAME_CENTRAL": "lizsync_central", "CONNECTION_NAME_CLONE": "lizsync_clone_a"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
ALGO="lizsync:synchronize_database"
PARAMS='{"CONNECTION_NAME_CENTRAL": "lizsync_central", "CONNECTION_NAME_CLONE": "lizsync_clone_b"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
ALGO="lizsync:synchronize_database"
PARAMS='{"CONNECTION_NAME_CENTRAL": "lizsync_central", "CONNECTION_NAME_CLONE": "lizsync_clone_a"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
ALGO="lizsync:synchronize_database"
PARAMS='{"CONNECTION_NAME_CENTRAL": "lizsync_central", "CONNECTION_NAME_CLONE": "lizsync_clone_b"}'
python3 lizsync/processing/standalone_processing_runner.py "${ALGO}" "${PARAMS}"
# See diff between databases
echo ""
echo "Display diff between databases"
echo "##########################"
echo "CENTRAL / CLONE A"
echo "##########################"
lizsync/test/data/quick_diff.sh lizsync_central lizsync_clone_a test
echo "##########################"
echo "CENTRAL / CLONE B"
echo "##########################"
lizsync/test/data/quick_diff.sh lizsync_central lizsync_clone_b test
echo "##########################"
echo "CLONE A / CLONE B"
echo "##########################"
lizsync/test/data/quick_diff.sh lizsync_clone_a lizsync_clone_b test