Skip to content

Commit 93a2dcd

Browse files
committed
fix tests
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent da86565 commit 93a2dcd

6 files changed

Lines changed: 21 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
4343
### Fixed
4444

4545
- Fix flaky connection integration test by replacing arbitrary sleep times with proper server readiness polling
46+
- Fix OpenSearch 2.8.0+ Tasks API compatibility by adding cancellation_time_millis field to TasksListTask struct
4647
- Fix OpenSearch 3.1.0+ API compatibility by adding phase_results_processors field to nodes API and time_in_execution fields to cluster pending tasks API
4748
- Fix OpenSearch 3.2.0+ API compatibility by adding max_last_index_request_timestamp and startree query fields across nodes stats, indices stats, and cat APIs, plus settings field to security plugin health API
4849
- Fix OpenSearch 3.3.0+ API compatibility by adding neural_search breaker, query_failed and startree_query_failed search fields, search pipeline system_generated fields across multiple APIs, plus ingestion_status field to cluster state API and jwks_uri field to security config API

opensearchapi/api_mget_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestMGet(t *testing.T) {
5353
context.Background(),
5454
opensearchapi.MGetReq{
5555
Index: testIndex,
56-
Body: strings.NewReader(`{"docs":[{"_id":"1"},{"_id":"2"}]}`),
56+
Body: strings.NewReader(fmt.Sprintf(`{"docs":[{"_id":"%s-1"},{"_id":"%s-2"}]}`, docIDPrefix, docIDPrefix)),
5757
},
5858
)
5959
require.Nil(t, err)

opensearchapi/api_mtermvectors_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestMTermvectors(t *testing.T) {
2626
client, err := ostest.NewClient(t)
2727
require.Nil(t, err)
2828

29-
testIndex := "test-mtermvectors"
29+
testIndex := testutil.MustUniqueString(t, "test-mtermvectors")
3030
t.Cleanup(func() {
3131
client.Indices.Delete(t.Context(), opensearchapi.IndicesDeleteReq{Indices: []string{testIndex}})
3232
})
@@ -95,7 +95,7 @@ func TestMTermvectors(t *testing.T) {
9595
t.Context(),
9696
opensearchapi.MTermvectorsReq{
9797
Index: testIndex,
98-
Body: strings.NewReader(`{"ids":[1,2]}`),
98+
Body: strings.NewReader(fmt.Sprintf(`{"ids":["%s-0","%s-1"]}`, docIDPrefix, docIDPrefix)),
9999
},
100100
)
101101
require.Nil(t, err)

opensearchapi/api_tasks-list.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,20 @@ type TasksListNodes struct {
5555

5656
// TasksListTask is a sub type of TaskListResp, TaskListNodes containing information about a task
5757
type TasksListTask struct {
58-
Node string `json:"node"`
59-
ID int `json:"id"`
60-
Type string `json:"type"`
61-
Action string `json:"action"`
62-
Description string `json:"description"`
63-
StartTimeInMillis int64 `json:"start_time_in_millis"`
64-
RunningTimeInNanos int64 `json:"running_time_in_nanos"`
65-
Cancellable bool `json:"cancellable"`
66-
Cancelled bool `json:"cancelled"`
67-
Headers map[string]string `json:"headers"`
68-
ResourceStats TasksListResourceStats `json:"resource_stats"`
69-
ParentTaskID string `json:"parent_task_id"`
70-
Children []TasksListTask `json:"children,omitempty"`
58+
Node string `json:"node"`
59+
ID int `json:"id"`
60+
Type string `json:"type"`
61+
Action string `json:"action"`
62+
Description string `json:"description"`
63+
StartTimeInMillis int64 `json:"start_time_in_millis"`
64+
RunningTimeInNanos int64 `json:"running_time_in_nanos"`
65+
Cancellable bool `json:"cancellable"`
66+
Cancelled bool `json:"cancelled"`
67+
CancellationTimeMillis *int64 `json:"cancellation_time_millis,omitempty"` // Added in OpenSearch 2.8.0
68+
Headers map[string]string `json:"headers"`
69+
ResourceStats TasksListResourceStats `json:"resource_stats"`
70+
ParentTaskID string `json:"parent_task_id"`
71+
Children []TasksListTask `json:"children,omitempty"`
7172
}
7273

7374
// TasksListResourceStats is a sub type of TaskListTask containing information about task stats

opensearchapi/api_termvectors_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func TestTermvectors(t *testing.T) {
2727
client, err := ostest.NewClient(t)
2828
require.Nil(t, err)
2929

30-
testIndex := "test-termvectors"
30+
testIndex := testutil.MustUniqueString(t, "test-termvectors")
3131
t.Cleanup(func() {
3232
client.Indices.Delete(t.Context(), opensearchapi.IndicesDeleteReq{Indices: []string{testIndex}})
3333
})
@@ -96,7 +96,7 @@ func TestTermvectors(t *testing.T) {
9696
context.Background(),
9797
opensearchapi.TermvectorsReq{
9898
Index: testIndex,
99-
DocumentID: "1",
99+
DocumentID: fmt.Sprintf("%s-%d", docIDPrefix, 0),
100100
Body: strings.NewReader(`{"fields":["*"],"offsets":true,"payloads":true,"positions":true,` +
101101
`"term_statistics":true,"field_statistics":true}`),
102102
},

opensearchapi/api_update_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestUpdate(t *testing.T) {
5454
opensearchapi.UpdateReq{
5555
Params: opensearchapi.UpdateParams{Source: true},
5656
Index: testIndex,
57-
DocumentID: "1",
57+
DocumentID: fmt.Sprintf("%s-%d", docIDPrefix, 1),
5858
Body: strings.NewReader(`{"script":{"source":"ctx._source.counter += params.count","lang":"painless","params":{"count":4}}}`),
5959
},
6060
)

0 commit comments

Comments
 (0)