Skip to content

Commit

Permalink
Make new spatial sort tests less flaky (elastic#106401)
Browse files Browse the repository at this point in the history
The tests that assert sorting on spatial types causes consistent error messages, also were flaky for the non-error message cases under rare circumstances where the results were returned in different order. We now sort those on a sortable field for deterministic behaviour.
  • Loading branch information
craigtaverner authored Mar 18, 2024
1 parent 1e0df87 commit d84b46c
Showing 1 changed file with 52 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ setup:
properties:
location:
type: geo_point
id:
type: integer

- do:
bulk:
index: geo_points
refresh: true
body:
- { "index": { } }
- { "location": "POINT(1 -1)" }
- { "id": 1, "location": "POINT(1 -1)" }
- { "index": { } }
- { "location": "POINT(-1 1)" }
- { "id": 2, "location": "POINT(-1 1)" }

- do:
indices.create:
Expand All @@ -32,16 +34,18 @@ setup:
properties:
location:
type: point
id:
type: integer

- do:
bulk:
index: cartesian_points
refresh: true
body:
- { "index": { } }
- { "location": "POINT(4321 -1234)" }
- { "id": 1, "location": "POINT(4321 -1234)" }
- { "index": { } }
- { "location": "POINT(-4321 1234)" }
- { "id": 2, "location": "POINT(-4321 1234)" }

- do:
indices.create:
Expand All @@ -51,16 +55,18 @@ setup:
properties:
shape:
type: geo_shape
id:
type: integer

- do:
bulk:
index: geo_shapes
refresh: true
body:
- { "index": { } }
- { "shape": "POINT(0 0)" }
- { "id": 1, "shape": "POINT(0 0)" }
- { "index": { } }
- { "shape": "POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))" }
- { "id": 2, "shape": "POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))" }

- do:
indices.create:
Expand All @@ -70,16 +76,18 @@ setup:
properties:
shape:
type: shape
id:
type: integer

- do:
bulk:
index: cartesian_shapes
refresh: true
body:
- { "index": { } }
- { "shape": "POINT(0 0)" }
- { "id": 1, "shape": "POINT(0 0)" }
- { "index": { } }
- { "shape": "POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))" }
- { "id": 2, "shape": "POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1))" }

---
geo_point:
Expand All @@ -88,12 +96,16 @@ geo_point:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'from geo_points'
- match: { columns.0.name: location }
- match: { columns.0.type: geo_point }
query: 'from geo_points | sort id'
- match: { columns.0.name: id }
- match: { columns.0.type: integer }
- match: { columns.1.name: location }
- match: { columns.1.type: geo_point }
- length: { values: 2 }
- match: { values.0.0: "POINT (1.0 -1.0)" }
- match: { values.1.0: "POINT (-1.0 1.0)" }
- match: { values.0.0: 1 }
- match: { values.1.0: 2 }
- match: { values.0.1: "POINT (1.0 -1.0)" }
- match: { values.1.1: "POINT (-1.0 1.0)" }

---
geo_point unsortable:
Expand Down Expand Up @@ -126,12 +138,16 @@ cartesian_point:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'from cartesian_points'
- match: { columns.0.name: location }
- match: { columns.0.type: cartesian_point }
query: 'from cartesian_points | sort id'
- match: { columns.0.name: id }
- match: { columns.0.type: integer }
- match: { columns.1.name: location }
- match: { columns.1.type: cartesian_point }
- length: { values: 2 }
- match: { values.0.0: "POINT (4321.0 -1234.0)" }
- match: { values.1.0: "POINT (-4321.0 1234.0)" }
- match: { values.0.0: 1 }
- match: { values.1.0: 2 }
- match: { values.0.1: "POINT (4321.0 -1234.0)" }
- match: { values.1.1: "POINT (-4321.0 1234.0)" }

---
cartesian_point unsortable:
Expand Down Expand Up @@ -164,12 +180,16 @@ geo_shape:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'from geo_shapes'
- match: { columns.0.name: shape }
- match: { columns.0.type: geo_shape }
query: 'from geo_shapes | sort id'
- match: { columns.0.name: id }
- match: { columns.0.type: integer }
- match: { columns.1.name: shape }
- match: { columns.1.type: geo_shape }
- length: { values: 2 }
- match: { values.0.0: "POINT (0.0 0.0)" }
- match: { values.1.0: "POLYGON ((-1.0 -1.0, 1.0 -1.0, 1.0 1.0, -1.0 1.0, -1.0 -1.0))" }
- match: { values.0.0: 1 }
- match: { values.1.0: 2 }
- match: { values.0.1: "POINT (0.0 0.0)" }
- match: { values.1.1: "POLYGON ((-1.0 -1.0, 1.0 -1.0, 1.0 1.0, -1.0 1.0, -1.0 -1.0))" }

---
geo_shape unsortable:
Expand Down Expand Up @@ -202,12 +222,16 @@ cartesian_shape:
- "No limit defined, adding default limit of \\[.*\\]"
esql.query:
body:
query: 'from cartesian_shapes'
- match: { columns.0.name: shape }
- match: { columns.0.type: cartesian_shape }
query: 'from cartesian_shapes | sort id'
- match: { columns.0.name: id }
- match: { columns.0.type: integer }
- match: { columns.1.name: shape }
- match: { columns.1.type: cartesian_shape }
- length: { values: 2 }
- match: { values.0.0: "POINT (0.0 0.0)" }
- match: { values.1.0: "POLYGON ((-1.0 -1.0, 1.0 -1.0, 1.0 1.0, -1.0 1.0, -1.0 -1.0))" }
- match: { values.0.0: 1 }
- match: { values.1.0: 2 }
- match: { values.0.1: "POINT (0.0 0.0)" }
- match: { values.1.1: "POLYGON ((-1.0 -1.0, 1.0 -1.0, 1.0 1.0, -1.0 1.0, -1.0 -1.0))" }

---
cartesian_shape unsortable:
Expand Down

0 comments on commit d84b46c

Please sign in to comment.