Skip to content

Commit 278ce98

Browse files
committed
test against real openSearch
1 parent fdf1f5f commit 278ce98

58 files changed

Lines changed: 962 additions & 1046 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/go-setup/action.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ description: 'Setup go and cache and go download mods'
44
runs:
55
using: "composite"
66
steps:
7-
- uses: actions/checkout@v4
87
- uses: actions/setup-go@v4
98
with:
109
cache: true

.github/workflows/codecov.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,29 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v5
1515
- uses: ./.github/actions/go-setup
16-
- run: |
17-
go test -v ./...
16+
- run: make test-codecov
17+
- name: Upload unit test coverage to Codecov
18+
uses: codecov/codecov-action@v5
19+
with:
20+
files: cov-unit-tests.out
21+
flags: unit-tests
22+
name: Unit Tests
23+
token: ${{ secrets.CODECOV_TOKEN }}
24+
fail_ci_if_error: true
25+
26+
opensearch-test:
27+
name: Execute Opensearch tests
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v5
31+
- uses: ./.github/actions/go-setup
32+
- name: Execute OpenSearch tests
33+
run: make test-opensearch
34+
- name: Upload OpenSearch test coverage to Codecov
35+
uses: codecov/codecov-action@v5
36+
with:
37+
files: cov-os-tests.out
38+
flags: opensearch-tests
39+
name: OpenSearch Tests
40+
token: ${{ secrets.CODECOV_TOKEN }}
41+
fail_ci_if_error: true

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
# common IDEs
12
.idea
3+
.vscode
4+
5+
# coverage reports
6+
*.out

Makefile

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ REGISTRY := docker-gps.greenbone.net
33
# Define submodules
44
PKG_DIR := pkg
55

6+
.PHONY: all
67
all: build test
78

89
.PHONY: help
@@ -27,6 +28,7 @@ OS="$(shell go env var GOOS | xargs)"
2728
ALL_GO_DIRS := $(shell find $(PKG_DIR) -name '*.go' -exec dirname {} \; | sort -u)
2829

2930
# Clean up
31+
.PHONY: clean
3032
clean:
3133
go clean -i ./...
3234

@@ -64,14 +66,35 @@ build: build-common ## build go library packages
6466
go build -trimpath ./...
6567

6668
.PHONY: test
67-
test: ## run all tests
68-
go test -test.short ./...
69+
test: ## run short tests
70+
go test -short ./...
6971

7072
.PHONY: test-codecov
7173
test-codecov:
72-
go test -cover -coverprofile=coverage.txt ./...
73-
74-
.PHONY: all build test clean
74+
go test -cover -coverprofile=cov-unit-tests.out ./...
75+
76+
.PHONY: start-opensearch-test-service
77+
start-opensearch-test-service:
78+
docker compose -f ./pkg/openSearch/ostesting/compose.yml -p opensearch-test up -d --wait --wait-timeout=120
79+
80+
.PHONY: stop-opensearch-test-service
81+
stop-opensearch-test-service:
82+
docker compose -f ./pkg/openSearch/ostesting/compose.yml -p opensearch-test down -v
83+
84+
.PHONY: run-opensearch-tests
85+
run-opensearch-tests:
86+
TEST_OPENSEARCH=1 go test ./pkg/openSearch/osquery -coverprofile=cov-os-tests.out
87+
88+
# test-opensearch runs whole opensearch execution with docker setup and cleanup
89+
# we want to stop-opensearch-test-service regardless of the result of run-opensearch-tests
90+
# and return the result of run-opensearch-tests
91+
.PHONY: test-opensearch
92+
test-opensearch:
93+
$(MAKE) start-opensearch-test-service
94+
$(MAKE) run-opensearch-tests; \
95+
status=$$?; \
96+
$(MAKE) stop-opensearch-test-service; \
97+
exit $$status
7598

7699
.PHONY: generate_docs
77100
generate_docs: check_tools

pkg/openSearch/osquery/boolQueryBuilderTestHelper_test.go

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)