Skip to content

Commit

Permalink
Fix: integration tests with unreleased version of OpenSearch. (#600)
Browse files Browse the repository at this point in the history
* Fix: integration tests with unreleased version of OpenSearch.

Signed-off-by: dblock <dblock@amazon.com>

* Added 1.3.18, 2.16.0, removed unsupported 1.x.

Signed-off-by: dblock <dblock@amazon.com>

* Fix: skip if below test cases.

Signed-off-by: dblock <dblock@amazon.com>

---------

Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock authored Aug 20, 2024
1 parent fde2c47 commit 4c0cf65
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ jobs:
matrix:
secured: ["true", "false"]
entry:
- { opensearch_version: 1.1.0 }
- { opensearch_version: 1.2.4 }
- { opensearch_version: 1.3.15 }
- { opensearch_version: 1.3.18 }
- { opensearch_version: 2.0.1 }
- { opensearch_version: 2.1.0 }
- { opensearch_version: 2.2.1 }
Expand All @@ -29,6 +27,7 @@ jobs:
- { opensearch_version: 2.13.0 }
- { opensearch_version: 2.14.0 }
- { opensearch_version: 2.15.0 }
- { opensearch_version: 2.16.0 }
steps:
- uses: actions/checkout@v4

Expand Down
26 changes: 14 additions & 12 deletions .github/workflows/test-integration-unreleased.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
name: Integration with Unreleased OpenSearch

on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
opensearch_ref: [ '1.x', '2.x', 'main' ]
entry:
- { branch: '1.x', java-version: '11' }
- { branch: '2.x', java-version: '17' }
- { branch: 'main', java-version: '17' }
steps:
- name: Checkout OpenSearch
uses: actions/checkout@v4
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.entry.opensearch_ref }}
ref: ${{ matrix.entry.branch }}
path: opensearch

- name: Get OpenSearch branch top
Expand All @@ -35,6 +32,11 @@ jobs:
path: opensearch/distribution/archives/linux-tar/build/distributions
key: ${{ steps.get-key.outputs.key }}

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: ${{ matrix.entry.java-version }}

- name: Assemble OpenSearch
if: steps.cache-restore.outputs.cache-hit != 'true'
working-directory: opensearch
Expand All @@ -53,7 +55,7 @@ jobs:
tar xf opensearch-min-*
./opensearch-*/bin/opensearch -Epath.repo=/usr/share/opensearch/mnt &
for attempt in {1..20}; do sleep 5; if curl -s localhost:9200; then echo '=====> ready'; break; fi; echo '=====> waiting...'; done
- name: Checkout Go Client
uses: actions/checkout@v4
with:
Expand All @@ -68,11 +70,11 @@ jobs:
run: make test-integ-core race=true
env:
OPENSEARCH_GO_SKIP_JSON_COMPARE: true

- name: Save server logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: opensearch-logs-${{ matrix.opensearch_ref }}-go-${{ matrix.python-version }}
name: opensearch-logs-${{ matrix.entry.branch }}
path: |
opensearch/distribution/archives/linux-tar/build/distributions/**/logs/*
2 changes: 1 addition & 1 deletion internal/test/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func SkipIfBelowVersion(t *testing.T, client *opensearchapi.Client, majorVersion
t.Helper()
major, patch, _, err := GetVersion(client)
assert.Nil(t, err)
if major <= majorVersion && patch <= patchVersion {
if major < majorVersion || (major == majorVersion && patch < patchVersion) {
t.Skipf("Skiping %s as version %d.%d.x does not support this endpoint", testName, major, patch)
}
}
Expand Down
4 changes: 2 additions & 2 deletions opensearchapi/api_cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func TestCatClient(t *testing.T) {
for catType, value := range testCases {
t.Run(catType, func(t *testing.T) {
if catType == "ClusterManager" {
ostest.SkipIfBelowVersion(t, client, 1, 3, catType)
ostest.SkipIfBelowVersion(t, client, 2, 0, catType)
}
for _, testCase := range value {
t.Run(testCase.Name, func(t *testing.T) {
Expand Down Expand Up @@ -399,7 +399,7 @@ func TestCatClient(t *testing.T) {
ostest.CompareRawJSONwithParsedJSON(t, resp.Allocations, resp.Inspect().Response)
})
t.Run("ClusterManager", func(t *testing.T) {
ostest.SkipIfBelowVersion(t, client, 1, 3, "ClusterManager")
ostest.SkipIfBelowVersion(t, client, 2, 0, "ClusterManager")
resp, err := client.Cat.ClusterManager(nil, nil)
assert.Nil(t, err)
assert.NotNil(t, resp)
Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func TestClusterClient(t *testing.T) {
for catType, value := range testCases {
t.Run(catType, func(t *testing.T) {
if strings.Contains(catType, "Decommission") {
ostest.SkipIfBelowVersion(t, client, 2, 3, catType)
ostest.SkipIfBelowVersion(t, client, 2, 4, catType)
}
for _, testCase := range value {
t.Run(testCase.Name, func(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions opensearchapi/api_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestScriptClient(t *testing.T) {
for _, value := range testCases {
t.Run(value.Name, func(t *testing.T) {
if strings.Contains(value.Name, "Language") {
ostest.SkipIfBelowVersion(t, client, 2, 3, value.Name)
ostest.SkipIfBelowVersion(t, client, 2, 4, value.Name)
}
for _, testCase := range value.Tests {
t.Run(testCase.Name, func(t *testing.T) {
Expand Down Expand Up @@ -206,7 +206,7 @@ func TestScriptClient(t *testing.T) {
ostest.CompareRawJSONwithParsedJSON(t, resp, resp.Inspect().Response)
})
t.Run("Language", func(t *testing.T) {
ostest.SkipIfBelowVersion(t, client, 2, 3, "Language")
ostest.SkipIfBelowVersion(t, client, 2, 4, "Language")
resp, err := client.Script.Language(nil, nil)
require.Nil(t, err)
assert.NotNil(t, resp)
Expand Down
4 changes: 2 additions & 2 deletions plugins/ism/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ func TestClient(t *testing.T) {
ostest.CompareRawJSONwithParsedJSON(t, &resp, resp.Inspect().Response)
})
t.Run("Explain with validate_action", func(t *testing.T) {
ostest.SkipIfBelowVersion(t, osClient, 2, 3, "Explain with validate_action")
ostest.SkipIfBelowVersion(t, osClient, 2, 4, "Explain with validate_action")
resp, err := client.Explain(nil, &ism.ExplainReq{Indices: testIndex, Params: ism.ExplainParams{ShowPolicy: true, ValidateAction: true}})
assert.Nil(t, err)
assert.NotNil(t, resp)
ostest.CompareRawJSONwithParsedJSON(t, &resp, resp.Inspect().Response)
})
t.Run("Explain with show_policy", func(t *testing.T) {
ostest.SkipIfBelowVersion(t, osClient, 1, 2, "Explain with validate_action")
ostest.SkipIfBelowVersion(t, osClient, 1, 3, "Explain with show_policy")
resp, err := client.Explain(nil, &ism.ExplainReq{Indices: testIndex, Params: ism.ExplainParams{ShowPolicy: true}})
assert.Nil(t, err)
assert.NotNil(t, resp)
Expand Down
4 changes: 2 additions & 2 deletions plugins/security/api_ssl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestSSLClient(t *testing.T) {
osAPIclient, err := ostest.NewClient()
require.Nil(t, err)

ostest.SkipIfBelowVersion(t, osAPIclient, 1, 3, "SSLClient")
ostest.SkipIfBelowVersion(t, osAPIclient, 2, 0, "SSLClient")

clientTLSCert, err := tls.LoadX509KeyPair("../../admin.pem", "../../admin.key")
require.Nil(t, err)
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestSSLClient(t *testing.T) {
for _, testCase := range value.Tests {
t.Run(testCase.Name, func(t *testing.T) {
if strings.HasSuffix(value.Name, "Reload") && strings.Contains(testCase.Name, "request") {
ostest.SkipIfBelowVersion(t, osAPIclient, 2, 7, value.Name)
ostest.SkipIfBelowVersion(t, osAPIclient, 2, 8, value.Name)
}
res, err := testCase.Results()
if testCase.Name == "inspect" {
Expand Down

0 comments on commit 4c0cf65

Please sign in to comment.