Skip to content

Commit

Permalink
fix rest api spec tests
Browse files Browse the repository at this point in the history
Signed-off-by: kkewwei <[email protected]>
  • Loading branch information
kkewwei committed Aug 2, 2024
1 parent 9e6e85a commit 2e32671
Showing 1 changed file with 50 additions and 55 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# The test setup includes two parts:
# part1: test mapping and indexing
# part2: test query
---
# The test setup includes:
# - Create two indices with constant_keyword field type
# - Index documents
# - Check mapping
# - Verify document count
# - Search rangeQuery and regexpQuery
# - Delete indices when connection is teardown
setup:
"Mappings and Indexing":
- skip:
version: " - 2.15.99"
reason: "fixed in 2.16.0"
Expand All @@ -22,16 +18,6 @@ setup:
type: "constant_keyword"
value: "1"

- do:
indices.create:
index: test1
body:
mappings:
properties:
genre:
type: "constant_keyword"
value: "d3efault"

# Index documents to test integer and string are both ok.
- do:
index:
Expand All @@ -49,35 +35,10 @@ setup:
"genre": 1
}

# Index documents to test query.
- do:
index:
index: test1
id: 1
body: {
"genre": "d3efault"
}

# Refresh
- do:
indices.refresh:
index: [test, test1]

---
# Delete Index when connection is teardown
teardown:
- skip:
version: " - 2.15.99"
reason: "fixed in 2.16.0"

- do:
indices.delete:
index: test,test1

---
"Mappings":
- skip:
version: " - 2.15.99"
reason: "fixed in 2.16.0"
index: test

# Check mapping
- do:
Expand All @@ -101,24 +62,41 @@ teardown:
- match: { hits.hits.0._source.genre: "1" }
- match: { hits.hits.1._source.genre: 1 }

# Delete Index when connection is teardown
- do:
search:
index: test1
body: {
query: {
match_all: {}
}
}

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.genre: "d3efault" }
indices.delete:
index: test

---
"Queries":
- skip:
version: " - 2.16.99"
reason: "fixed in 2.17.0"

- do:
indices.create:
index: test1
body:
mappings:
properties:
genre:
type: "constant_keyword"
value: "d3efault"

# Index documents to test query.
- do:
index:
index: test1
id: 1
body: {
"genre": "d3efault"
}

# Refresh
- do:
indices.refresh:
index: test1

# Test rangeQuery
- do:
search:
Expand Down Expand Up @@ -335,3 +313,20 @@ teardown:
}

- length: { hits.hits: 0 }

- do:
search:
index: test1
body: {
query: {
match_all: {}
}
}

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.genre: "d3efault" }

# Delete Index when connection is teardown
- do:
indices.delete:
index: test1

0 comments on commit 2e32671

Please sign in to comment.