Skip to content

Commit

Permalink
Use go:build tags for testing (#529)
Browse files Browse the repository at this point in the history
* add more go:build tags to tests

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

* opensearch: remove unneeded security integ test as it is covert in the normal integ test

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

* makefile: use build tags for testing

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

* github/workflow: use new make commands for integ tests

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

* add changelog

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

---------

Signed-off-by: Jakob Hahn <[email protected]>
  • Loading branch information
Jakob3xD authored Apr 16, 2024
1 parent 135aca0 commit d98790b
Show file tree
Hide file tree
Showing 64 changed files with 81 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: |
export OPENSEARCH_VERSION=${{ matrix.entry.opensearch_version }}
export SECURE_INTEGRATION=${{ matrix.secured }}
make cluster.get-cert test-integ race=true
make cluster.get-cert test-integ-core test-integ-plugins race=true
- name: Stop the OpenSearch cluster
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-integration-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:

- name: Integration test
working-directory: go-client
run: make test-integ race=true unreleased=true
run: make test-integ-core race=true
env:
OPENSEARCH_GO_SKIP_JSON_COMPARE: true

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
for attempt in `seq 25`; do sleep 5; \
if curl -s localhost:9200; \
then echo '=====> ready'; break; fi; if [ $attempt == 25 ]; then exit 1; fi; echo '=====> waiting...'; done
- run: make test-integ race=true
- run: make test-integ-core test-integ-plugins race=true

secured:
name: Tests against secure cluster
Expand All @@ -50,7 +50,7 @@ jobs:
for attempt in `seq 25`; do sleep 5; \
if curl -s -ku admin:myStrongPassword123! https://localhost:9200; \
then echo '=====> ready'; break; fi; if [ $attempt == 25 ]; then exit 1; fi; echo '=====> waiting...'; done
- run: make cluster.get-cert test-integ-secure race=true coverage=true
- run: make cluster.get-cert test-integ-core test-integ-plugins race=true coverage=true
- uses: codecov/codecov-action@v4
with:
file: tmp/integ.cov
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Adjust workflows to work with security plugin ([#507](https://github.com/opensearch-project/opensearch-go/pull/507))
- Updates USER_GUIDE.md and /_samples/ ([#518](https://github.com/opensearch-project/opensearch-go/pull/518))
- Updates opensearchtransport.Client to use pooled gzip writer and buffer ([#521](https://github.com/opensearch-project/opensearch-go/pull/521))
- Use go:build tags for testing ([#52?](https://github.com/opensearch-project/opensearch-go/pull/52?))

### Deprecated

Expand Down Expand Up @@ -200,4 +201,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
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,37 @@ test: test-unit

test-integ: ## Run integration tests
@printf "\033[2m→ Running integration tests...\033[0m\n"
$(eval testintegtags += "integration")
$(eval testintegpath = "./...")
$(eval testintegtags += "integration,core,plugins")
ifdef multinode
$(eval testintegtags += "multinode")
endif
ifdef race
$(eval testintegargs += "-race")
endif
ifdef unreleased
$(eval testintegpath = "./opensearchapi/...")
endif
$(eval testintegargs += "-cover" "-tags=$(testintegtags)" "-timeout=1h" "$(testintegpath)" "-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);
ifdef coverage
@go tool covdata textfmt -i=$(PWD)/tmp/integration -o $(PWD)/tmp/integ.cov
endif

test-integ-core: ## Run base integration tests
@make test-integ testintegtags=integration,core

test-integ-plugins: ## Run plugin integration tests
@make test-integ testintegtags=integration,plugins

test-integ-secure: ##Run secure integration tests
@SECURE_INTEGRATION=true make test-integ

test-integ-core-secure: ## Run secure base integration tests
@SECURE_INTEGRATION=true make test-integ testintegtags=integration,core

test-integ-plugins-secure: ## Run secure plugin integration tests
@SECURE_INTEGRATION=true make test-integ testintegtags=integration,plugins


test-bench: ## Run benchmarks
@printf "\033[2m→ Running benchmarks...\033[0m\n"
go test -run=none -bench=. -benchmem ./...
Expand Down
2 changes: 1 addition & 1 deletion opensearch_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// specific language governing permissions and limitations
// under the License.

//go:build integration && !multinode
//go:build integration && core && !multinode

package opensearch_test

Expand Down
52 changes: 0 additions & 52 deletions opensearch_secure_integration_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion opensearchapi/api_aliases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_bulk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_cat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

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 @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_component_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_dangling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_datastream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_index_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_indices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_mget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_msearch-template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_msearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_mtermvectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_nodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_point_in_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_rank_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_reindex_rethrottle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_reindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_render_search_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_scroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
2 changes: 1 addition & 1 deletion opensearchapi/api_search-template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// this file be licensed under the Apache-2.0 license or a
// compatible open source license.
//
//go:build integration
//go:build integration && (core || opensearchapi)

package opensearchapi_test

Expand Down
Loading

0 comments on commit d98790b

Please sign in to comment.