Skip to content

Commit

Permalink
Adjust tests to work with secure cluster (#488)
Browse files Browse the repository at this point in the history
* internal: move some functions from opensearchapi/internal, add functions to create sure client

Signed-off-by: Jakob Hahn <[email protected]>

* Makefile: adjust test-integ-secure to run test-integ with SECURE_INTEGRATION set to true

Signed-off-by: Jakob Hahn <[email protected]>

* .github/workflows: adjust compatibility test to run test with exported SECURE_INTEGRATION env

Signed-off-by: Jakob Hahn <[email protected]>

* .github/workflows: update action version

Signed-off-by: Jakob Hahn <[email protected]>

* adjust tests to run on secure and unsecure clusters depending on env

Signed-off-by: Jakob Hahn <[email protected]>

* add changelog

Signed-off-by: Jakob Hahn <[email protected]>

* golangci: adjust config for internal folder

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: indices segments add missing merge_id field

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: change custom_foldername field to pointer as it can be null

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: skip render search template test if secure and version 2.11 or 2.10

Signed-off-by: Jakob Hahn <[email protected]>

* opensearchapi: changed cat indices Primary and Replica field to pointer as it can be null

Signed-off-by: Jakob Hahn <[email protected]>

---------

Signed-off-by: Jakob Hahn <[email protected]>
  • Loading branch information
Jakob3xD authored Mar 14, 2024
1 parent 5631d3c commit c72a471
Show file tree
Hide file tree
Showing 60 changed files with 551 additions and 351 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog_verifier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
verify-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependabot_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
installation_id: 22958780

- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ steps.github_app_token.outputs.token }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check license headers
run: |
./.github/check-license-headers.sh
./.github/check-license-headers.sh
2 changes: 1 addition & 1 deletion .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: lychee Link Checker
id: lychee
uses: lycheeverse/[email protected]
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/setup-go@v3
with: { go-version: '1.x' }
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -25,8 +24,7 @@ jobs:
name: Prettify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/checkout@v4
- name: Install dependencies
run: npm i -g npm@8 && npm i -g prettier
- name: Check markdown files
Expand Down
20 changes: 8 additions & 12 deletions .github/workflows/test-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
entry:
- { opensearch_version: 1.1.0 }
- { opensearch_version: 1.2.4 }
- { opensearch_version: 1.3.8 }
- { opensearch_version: 1.3.15 }
- { opensearch_version: 2.0.1 }
- { opensearch_version: 2.1.0 }
- { opensearch_version: 2.2.1 }
Expand All @@ -24,14 +24,13 @@ jobs:
- { opensearch_version: 2.8.0 }
- { opensearch_version: 2.9.0 }
- { opensearch_version: 2.10.0 }
- { opensearch_version: 2.11.0 }
- { opensearch_version: 2.11.1 }
- { opensearch_version: 2.12.0 }
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/checkout@v4

- uses: actions/setup-go@v3
with: { go-version: '1.x' }
- uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }

- run: go version

Expand All @@ -51,15 +50,12 @@ jobs:
if curl -s $(if $SECURE_INTEGRATION; then echo "-ku admin:admin https://"; fi)localhost:9200; \
then echo '=====> ready'; break; fi; if [ $attempt == 25 ]; then exit 1; fi; echo '=====> waiting...'; done
- name: Integration test without security
if: ${{ matrix.secured == 'false'}}
- name: Integration test
run: |
export OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }}
export SECURE_INTEGRATION=${{ matrix.secured }}
make test-integ race=true
- name: Integration test with security
if: ${{ matrix.secured == 'true'}}
run: make test-integ-secure

- name: Stop the OpenSearch cluster
run: |
make cluster.stop
14 changes: 7 additions & 7 deletions .github/workflows/test-integration-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
opensearch_ref: [ '1.x', '2.x', 'main' ]
steps:
- name: Checkout OpenSearch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: opensearch-project/OpenSearch
ref: ${{ matrix.entry.opensearch_ref }}
Expand All @@ -30,7 +30,7 @@ jobs:

- name: Restore cached build
id: cache-restore
uses: actions/cache/restore@v3
uses: actions/cache/restore@v4
with:
path: opensearch/distribution/archives/linux-tar/build/distributions
key: ${{ steps.get-key.outputs.key }}
Expand All @@ -42,7 +42,7 @@ jobs:

- name: Save cached build
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
uses: actions/cache/save@v4
with:
path: opensearch/distribution/archives/linux-tar/build/distributions
key: ${{ steps.get-key.outputs.key }}
Expand All @@ -55,13 +55,13 @@ jobs:
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@v3
uses: actions/checkout@v4
with:
path: go-client

- name: Setup Go
uses: actions/setup-go@v3
with: { go-version: '1.x' }
uses: actions/setup-go@v5
with: { go-version-file: 'go-client/go.mod' }

- name: Integration test
working-directory: go-client
Expand All @@ -71,7 +71,7 @@ jobs:

- name: Save server logs
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: opensearch-logs-${{ matrix.opensearch_ref }}-go-${{ matrix.python-version }}
path: |
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ jobs:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/setup-go@v3
with: { go-version: '1.x' }
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }
- run: go version
- name: Increase system limits
run: |
Expand All @@ -39,10 +38,9 @@ jobs:
env:
SECURE_INTEGRATION: true
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/setup-go@v3
with: { go-version: '1.x' }
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }
- run: go version
- name: Increase system limits
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-unit-tip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
bash make.bash
echo "GOROOT=$GOROOT" >> $GITHUB_ENV
echo "$GOROOT/bin" >> $GITHUB_PATH
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/checkout@v4
- run: go version
- run: make test-unit race=true
15 changes: 6 additions & 9 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
go: ['1.x']
fail-fast: false
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/setup-go@v3
with: { go-version: "${{ matrix.go }}" }
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }
- run: go version
- run: make test-unit race=true
if: matrix.os != 'ubuntu-latest'
Expand All @@ -34,9 +32,8 @@ jobs:
name: Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with: { fetch-depth: 1 }
- uses: actions/setup-go@v3
with: { go-version: '1.x' }
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version-file: 'go.mod' }
- run: go version
- run: make test-bench
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ issues:
- EXC0012
- EXC0014
exclude-rules:
- path: (_test\.go|opensearchapi/internal)
- path: (_test\.go|internal/)
linters:
- cyclop
- dupl
Expand All @@ -152,7 +152,7 @@ issues:
- linters:
- gosec
text: "TLS InsecureSkipVerify set true"
path: _test\.go
path: (_test\.go|internal/)
- linters:
- gosec
text: "G108: Profiling endpoint is automatically exposed on /debug/pprof"
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
- Added new struct fields introduced by opensearch 2.12 ([#482](https://github.com/opensearch-project/opensearch-go/pull/482))
- Adds initial admin password environment variable and CI changes to support 2.12.0 release ([#449](https://github.com/opensearch-project/opensearch-go/pull/449))
- Adds merge_id field for indices segement request ([#488](https://github.com/opensearch-project/opensearch-go/pull/488))
### Changed
- Updated workflow action versions ([#488](https://github.com/opensearch-project/opensearch-go/pull/488))
- Changed integration tests to work with secure and unsecure opensearch ([#488](https://github.com/opensearch-project/opensearch-go/pull/488))
- Moved functions from opensearch/internal/test to internal/test for more general test uses ([#488](https://github.com/opensearch-project/opensearch-go/pull/488))
- Changed custom_foldername field to pointer as it can be null ([#488](https://github.com/opensearch-project/opensearch-go/pull/488))
- Changed cat indices Primary and Replica field to pointer as it can be null ([#488](https://github.com/opensearch-project/opensearch-go/pull/488))
### Deprecated
### Removed
### Fixed
Expand Down Expand Up @@ -145,4 +151,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
[2.1.0]: https://github.com/opensearch-project/opensearch-go/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/opensearch-project/opensearch-go/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/opensearch-project/opensearch-go/compare/v1.1.0...v2.0.0
[1.0.0]: https://github.com/opensearch-project/opensearch-go/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/opensearch-project/opensearch-go/compare/v1.0.0...v1.1.0
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ endif
ifdef race
$(eval testintegargs += "-race")
endif
$(eval testintegargs += "-cover" "-tags='$(testintegtags)'" "-timeout=1h" "./..." "-args" "-test.gocoverdir=$(PWD)/tmp/integration")
$(eval testintegargs += "-cover" "-tags=$(testintegtags)" "-timeout=1h" "./..." "-args" "-test.gocoverdir=$(PWD)/tmp/integration")
@mkdir -p $(PWD)/tmp/integration
@echo "go test -v" $(testintegargs); \
go test -v $(testintegargs);
Expand All @@ -37,7 +37,7 @@ ifdef coverage
endif

test-integ-secure: ##Run secure integration tests
go test -tags=secure,integration ./opensearch_secure_integration_test.go
@SECURE_INTEGRATION=true make test-integ

test-bench: ## Run benchmarks
@printf "\033[2m→ Running benchmarks...\033[0m\n"
Expand Down
Loading

0 comments on commit c72a471

Please sign in to comment.