Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include integration testing against unreleased version #53

Merged
merged 4 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/integration-test-unreleased.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Integration with Unreleased OpenSearch
on:
push:
branches:
- main
- opensearch-*
pull_request:
branches:
- main
- opensearch-*
env:
OPENSEARCH_VERSION: '2.0'

jobs:
integ-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ 11 ]
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Checkout OpenSearch
uses: actions/checkout@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actions/checkout@v3 is also available

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

with:
repository: opensearch-project/opensearch
ref: ${{ env.OPENSEARCH_VERSION }}
path: opensearch

- name: Assemble OpenSearch
run: |
cd opensearch
./gradlew assemble
# This step runs the docker image generated during gradle assemble in OpenSearch. It is tagged as opensearch:test.
# Reference: https://github.com/opensearch-project/OpenSearch/blob/2.0/distribution/docker/build.gradle#L190
- name: Run Docker Image
run: |
docker run -p 9200:9200 -p 9600:9600 -d -e "discovery.type=single-node" -e "bootstrap.memory_lock=true" opensearch:test
sleep 90

- name: Set up Go ubuntu-latest
uses: actions/setup-go@v2
with:
go-version: 1.16.2

- name: Check out source code
uses: actions/checkout@v2

- name: Run Integration Tests
env:
GOPROXY: "https://proxy.golang.org"
OPENSEARCH_ENDPOINT: "http://localhost:9200"
run: |
go test -tags=integration ./it/platform/...
4 changes: 2 additions & 2 deletions it/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func (a *CLISuite) ValidateProfile() error {
if a.Profile.Endpoint == "" {
return fmt.Errorf("endpoint cannot be empty. set env %s", environment.OPENSEARCH_ENDPOINT)
}
if a.Profile.UserName == "" {
return fmt.Errorf("user cannot be empty. set env %s", environment.OPENSEARCH_USER)
if len(a.Profile.UserName) == 0 {
return nil
}
if a.Profile.Password == "" {
return fmt.Errorf("password cannot be empty. set env %s", environment.OPENSEARCH_PASSWORD)
Expand Down
10 changes: 3 additions & 7 deletions it/platform/curl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@ func (a *OpenSearchTestSuite) TestCurlGet() {
var health map[string]interface{}
assert.NoError(t, json.Unmarshal(response, &health))
assert.True(t, len(health) > 0)
assert.EqualValues(t, "yellow", health["status"])
assert.EqualValues(t, "test-cluster", health["cluster_name"])
assert.EqualValues(t, 1.0, health["number_of_nodes"])
assert.NotNil(t, health["status"])
assert.NotNil(t, health["number_of_nodes"])
})
a.T().Run("health status of a cluster in yaml", func(t *testing.T) {
ctx := context.Background()
Expand All @@ -114,15 +113,12 @@ func (a *OpenSearchTestSuite) TestCurlGet() {
assert.NoError(t, err, "failed to get response")
assert.NotNil(t, response)
var health struct {
Name string `yaml:"cluster_name"`
Nodes string `yaml:"number_of_nodes"`
Status string `yaml:"status"`
}
assert.NoError(t, yaml.Unmarshal(response, &health))
assert.True(t, len(health.Status) > 0)
assert.EqualValues(t, "yellow", health.Status)
assert.EqualValues(t, "test-cluster", health.Name)
assert.EqualValues(t, "1", health.Nodes)
assert.True(t, len(health.Nodes) > 0)
})
}

Expand Down