File: replication.feature

package info (click to toggle)
osm2pgsql 2.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,772 kB
  • sloc: cpp: 60,940; python: 1,115; ansic: 763; sh: 25; makefile: 14
file content (416 lines) | stat: -rw-r--r-- 19,320 bytes parent folder | download | duplicates (4)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
Feature: Tests for the osm2pgsql-replication script with property table

    Scenario: Replication can be initialised with an osm file after import
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3
            """
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-03T19:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init | --osm-file={TEST_DATA_DIR}/liechtenstein-2013-08-03.osm.pbf |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 9999999                                         |
            | replication_timestamp       | 2013-08-03T19:00:02Z                            |


    Scenario: Replication will be initialised from the information of the import file
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-03T19:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 9999999                                         |
            | replication_timestamp       | 2013-08-03T19:00:02Z                            |


    Scenario: Replication cannot be initialised when date information is missing
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3
            """
        When running osm2pgsql pgsql with parameters
            | --slim |

        Then running osm2pgsql-replication fails with returncode 1
            | init |
        And the error output contains
            """
            Cannot get timestamp from database.
            """

    Scenario: Replication cannot initialised on non-updatable database
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        When running osm2pgsql pgsql

        Then running osm2pgsql-replication fails with returncode 1
            | init |
        And the error output contains
            """
            Database needs to be imported in --slim mode.
            """

    Scenario: Replication can be initialised for a database in a different schema (middle-schema)
        Given the database schema foobar
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-03T19:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim | --middle-schema=foobar |

        And running osm2pgsql-replication
            | init | --middle-schema=foobar |

        Then table foobar.osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 9999999                                         |
            | replication_timestamp       | 2013-08-03T19:00:02Z                            |


    Scenario: Replication can be initialised for a database in a different schema (schema)
        Given the database schema foobar
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-03T19:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim | --schema=foobar |

        And running osm2pgsql-replication
            | init | --schema=foobar |

        Then table foobar.osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 9999999                                         |
            | replication_timestamp       | 2013-08-03T19:00:02Z                            |


    Scenario: Replication can be initialised for a database in a different schema (schema)
        Given the database schema foobar
        Given the database schema baz
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-03T19:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim | --middle-schema=foobar | --schema=baz |

        And running osm2pgsql-replication
            | init | --middle-schema=foobar | --schema=baz |

        Then table foobar.osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 9999999                                         |
            | replication_timestamp       | 2013-08-03T19:00:02Z                            |


    Scenario: Replication initialisation will fail for a database in a different schema
        Given the database schema foobar
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
        When running osm2pgsql pgsql with parameters
            | --slim |

        Then running osm2pgsql-replication fails with returncode 1
            | init | --middle-schema=foobar |
        And the error output contains
            """
            Database needs to be imported in --slim mode.
            """

    Scenario: Replication can be initialised with a fixed date (no previous replication info)
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3
            """
        And the replication service at https://planet.openstreetmap.org/replication/minute
            | sequence | timestamp            |
            | 345      | 2020-10-04T01:00:00Z |
            | 346      | 2020-10-04T02:00:00Z |
            | 347      | 2020-10-04T03:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init | --start-at | 2020-10-04T01:30:00Z |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | https://planet.openstreetmap.org/replication/minute |
            | replication_sequence_number | 345                                             |
            | replication_timestamp       | 2020-10-04T01:30:00Z                            |


    Scenario: Replication can be initialised with a fixed date (with previous replication info)
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 345      | 2020-10-04T01:00:00Z |
            | 346      | 2020-10-04T02:00:00Z |
            | 347      | 2020-10-04T03:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init | --start-at | 2020-10-04T03:30:00Z |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 347                                             |
            | replication_timestamp       | 2020-10-04T03:30:00Z                            |


    Scenario: Replication can be initialised from database date
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3 t2020-10-04T04:00:01Z
            """
        And the replication service at https://planet.openstreetmap.org/replication/minute
            | sequence | timestamp            |
            | 345      | 2020-10-04T01:00:00Z |
            | 346      | 2020-10-04T02:00:00Z |
            | 347      | 2020-10-04T03:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | https://planet.openstreetmap.org/replication/minute |
            | replication_sequence_number | 345                                             |
            | replication_timestamp       | 2020-10-04T01:00:01Z                            |


    Scenario: Replication can be initialised with a rollback (no previous replication info)
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3 t2020-10-04T02:00:01Z
            """
        And the replication service at https://planet.openstreetmap.org/replication/minute
            | sequence | timestamp            |
            | 345      | 2020-10-04T01:00:00Z |
            | 346      | 2020-10-04T02:00:00Z |
            | 347      | 2020-10-04T03:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init | --start-at | 60 |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | https://planet.openstreetmap.org/replication/minute |
            | replication_sequence_number | 345                                             |
            | replication_timestamp       | 2020-10-04T01:00:01Z                            |


    Scenario: Replication can be initialised with a rollback (with previous replication info)
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 344      | 2013-08-03T13:00:02Z |
            | 345      | 2013-08-03T14:00:02Z |
            | 346      | 2013-08-03T15:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init | --start-at | 60 |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 345                                             |
            | replication_timestamp       | 2013-08-03T14:55:30Z                            |


    Scenario: Replication can be initialised from a different server
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at https://custom.replication
            | sequence | timestamp            |
            | 1345     | 2013-07-01T01:00:00Z |
            | 1346     | 2013-08-01T01:00:00Z |
            | 1347     | 2013-09-01T01:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | init | --server | https://custom.replication |

        Then table osm2pgsql_properties contains
            | property                    | value                      |
            | replication_base_url        | https://custom.replication |
            | replication_sequence_number | 1346                       |
            | replication_timestamp       | 2013-08-03T12:55:30Z       |


    Scenario: Updates need an initialised replication
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3
            """
        And the replication service at https://planet.openstreetmap.org/replication/minute
        When running osm2pgsql pgsql with parameters
            | --slim |

        Then running osm2pgsql-replication fails with returncode 1
            | update |
        And the error output contains
            """
            Updates not set up correctly.
            """

    Scenario: Updates run until the end (exactly one application)
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-01T01:00:02Z |
            | 10000000 | 2013-09-01T01:00:00Z |
            | 10000001 | 2013-10-01T01:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |
        And running osm2pgsql-replication
            | init |
        And running osm2pgsql-replication
            | update |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 10000001                                        |
            | replication_timestamp       | 2013-10-01T01:00:00Z                            |


    Scenario: Updates run until the end (multiple applications)
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-01T01:00:02Z |
            | 10000000 | 2013-09-01T01:00:00Z |
            | 10000001 | 2013-10-01T01:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |
        And running osm2pgsql-replication
            | init |
        And running osm2pgsql-replication
            | update | --max-diff-size | 1 |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 10000001                                        |
            | replication_timestamp       | 2013-10-01T01:00:00Z                            |


    Scenario: Updates can run only once
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-01T01:00:02Z |
            | 10000000 | 2013-09-01T01:00:00Z |
            | 10000001 | 2013-10-01T01:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |
        And running osm2pgsql-replication
            | init |
        And running osm2pgsql-replication
            | update | --once | --max-diff-size | 1 |

        Then table osm2pgsql_properties contains
            | property                    | value                                           |
            | replication_base_url        | http://example.com/europe/liechtenstein-updates |
            | replication_sequence_number | 10000000                                        |
            | replication_timestamp       | 2013-09-01T01:00:00Z                            |


    Scenario: Status of an uninitialised database fails
        Given the OSM data
            """
            n34 Tamenity=restaurant x77 y45.3
            """
        And the replication service at https://planet.openstreetmap.org/replication/minute
        When running osm2pgsql pgsql with parameters
            | --slim |

        Then running osm2pgsql-replication fails with returncode 2
            | status | --json |
        And the standard output contains
            """
            "status": 2
            "error": "Updates not set up correctly.
            """

    Scenario: Status of a freshly initialised database
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 9999999  | 2013-08-01T01:00:02Z |
            | 10000000 | 2013-09-01T01:00:00Z |
            | 10000001 | 2013-10-01T01:00:00Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        And running osm2pgsql-replication
            | status | --json |
        Then the standard output contains
            """
            "status": 0
            "server": {"base_url": "http://example.com/europe/liechtenstein-updates", "sequence": 10000001, "timestamp": "2013-10-01T01:00:00Z"
            "local": {"sequence": 9999999, "timestamp": "2013-08-03T19:00:02Z"
            """


    Scenario: Replication initialisation will fail when diffs are not old enough
        Given the database schema foobar
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 10000000 | 2020-01-01T01:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        Then running osm2pgsql-replication fails with returncode 1
            | init | --server | http://example.com/europe/liechtenstein-updates |
        And the error output contains
            """
            The replication service does not have diff files for the requested date.
            """


    Scenario: Replication initialisation will fail when diffs are not old enough
        Given the database schema foobar
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the replication service at http://example.com/europe/liechtenstein-updates
            | sequence | timestamp            |
            | 10000000 | 2020-01-01T01:00:02Z |
        When running osm2pgsql pgsql with parameters
            | --slim |

        Then running osm2pgsql-replication fails with returncode 1
            | init |
        And the error output contains
            """
            Cannot load state information for 9999999 from replication service http://example.com/europe/liechtenstein-updates.
            """