diff --git a/.github/workflows/integration-test-unreleased.yml b/.github/workflows/integration-test-unreleased.yml new file mode 100644 index 0000000..091bc94 --- /dev/null +++ b/.github/workflows/integration-test-unreleased.yml @@ -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@v3 + 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@v3 + + - name: Run Integration Tests + env: + GOPROXY: "https://proxy.golang.org" + OPENSEARCH_ENDPOINT: "http://localhost:9200" + run: | + go test -tags=integration ./it/platform/... diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 44dc62a..497826b 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -23,7 +23,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run Docker Image env: diff --git a/.github/workflows/test-build-workflow.yml b/.github/workflows/test-build-workflow.yml index 03d924b..509b190 100644 --- a/.github/workflows/test-build-workflow.yml +++ b/.github/workflows/test-build-workflow.yml @@ -22,7 +22,7 @@ jobs: run: go get golang.org/x/tools/cmd/goimports - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Format check run: goimports -w . @@ -74,7 +74,7 @@ jobs: go-version: ${{ matrix.go-version }} - name: Check out source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build for ${{ matrix.platform }}-${{ matrix.go-version }} env: diff --git a/it/helper.go b/it/helper.go index 12736f9..8ffb344 100644 --- a/it/helper.go +++ b/it/helper.go @@ -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) diff --git a/it/platform/curl_test.go b/it/platform/curl_test.go index da189e5..b7de9d7 100644 --- a/it/platform/curl_test.go +++ b/it/platform/curl_test.go @@ -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() @@ -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) }) }