Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit 9348b71

Browse files
authored
Merge pull request #104 from mdelapenya/use-go-test-as-runner
Use "go test" as test runner
2 parents c36fbd2 + 8720619 commit 9348b71

12 files changed

Lines changed: 151 additions & 49 deletions

File tree

.ci/scripts/functional-test.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ rm -rf outputs || true
3535
mkdir -p outputs
3636

3737
## Parse FEATURE if not ALL then enable the flags to be passed to the functional-test wrapper
38-
FLAG=''
3938
REPORT=''
4039
if [ "${FEATURE}" != "" ] && [ "${FEATURE}" != "all" ] ; then
41-
FLAG='-t'
4240
REPORT=outputs/TEST-${FEATURE}
4341
else
4442
FEATURE=''
@@ -48,11 +46,12 @@ fi
4846
## Generate test report even if make failed.
4947
set +e
5048
exit_status=0
51-
if ! FLAG=${FLAG} FEATURE=${FEATURE} FORMAT=junit STACK_VERSION=${STACK_VERSION} METRICBEAT_VERSION=${METRICBEAT_VERSION} make --no-print-directory -C e2e functional-test | tee ${REPORT} ; then
49+
if ! FEATURE=${FEATURE} FORMAT=junit STACK_VERSION=${STACK_VERSION} METRICBEAT_VERSION=${METRICBEAT_VERSION} make --no-print-directory -C e2e functional-test | tee ${REPORT} ; then
5250
echo 'ERROR: functional-test failed'
5351
exit_status=1
5452
fi
5553

5654
## Transform report to Junit by parsing the stdout generated previously
55+
sed -i "s/testing: warning: no tests to run//" ${REPORT}
5756
sed -e 's/^[ \t]*//; s#>.*failed$#>#g' ${REPORT} | grep -E '^<.*>$' > ${REPORT}.xml
5857
exit $exit_status

e2e/Makefile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ STACK_VERSION?=
88
METRICBEAT_VERSION?=
99
VERSION_VALUE=`cat ../cli/VERSION.txt`
1010

11-
ifneq ($(FEATURE),)
12-
FEATURE_FLAG=--tags
13-
endif
14-
1511
GO_IMAGE_TAG?='stretch'
1612
GOOS?='linux'
1713
GOARCH?='amd64'
@@ -26,20 +22,15 @@ fetch-binary:
2622
install:
2723
go get -v -t ./...
2824

29-
.PHONY: install-godog
30-
install-godog: export GO111MODULE := on
31-
install-godog:
32-
go get -v github.com/cucumber/godog/cmd/godog@v0.9.0
33-
3425
.PHONY: functional-test
35-
functional-test: install-godog
26+
functional-test:
3627
OP_LOG_LEVEL=${LOG_LEVEL} \
3728
OP_LOG_INCLUDE_TIMESTAMP=${LOG_INCLUDE_TIMESTAMP} \
3829
OP_QUERY_MAX_ATTEMPTS=${QUERY_MAX_ATTEMPTS} \
3930
OP_RETRY_TIMEOUT=${RETRY_TIMEOUT} \
4031
OP_METRICBEAT_VERSION=${METRICBEAT_VERSION} \
4132
OP_STACK_VERSION=${STACK_VERSION} \
42-
godog --format=${FORMAT} ${FEATURE_FLAG} ${FEATURE}
33+
go test -v --godog.format=${FORMAT} ${FEATURE}
4334

4435
.PHONY: run-elastic-stack
4536
run-elastic-stack:

e2e/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Ok, you want to contribute the tests for a new integration module. Then you have
5252
- A `configuration file`, in YAML format, with any Metricbeat configuration that is specific to the module.
5353

5454
### Feature files
55-
We will create use cases for the module in a separate `.feature` file, ideally named after module's name (i.e. _apache.feature_). This feature file is a Cucumber requirement, that will be parsed by the test runner and matched against the Golang code implementing the tests.
55+
We will create use cases for the module in a separate `.feature` file, ideally named after module's name (i.e. _apache.feature_), and located under the `metricbeat` features directory. This feature file is a Cucumber requirement, that will be parsed by the test runner and matched against the Golang code implementing the tests.
5656

5757
```cucumber
5858
@apache
@@ -61,15 +61,17 @@ Feature: As a Metricbeat developer I want to check that the Apache module works
6161
Scenario Outline: Check module is sending metrics to Elasticsearch without errors
6262
Given Apache "<apache_version>" is running for metricbeat
6363
And metricbeat is installed and configured for Apache module
64+
And metricbeat waits "20" seconds for the service
65+
When metricbeat runs for "20" seconds
6466
Then there are "Apache" events in the index
6567
And there are no errors in the index
6668
Examples:
6769
| apache_version |
68-
| 2.2 |
69-
| 2.4 |
70+
| 2.4.12 |
71+
| 2.4.20 |
7072
```
7173

72-
>You should write as many scenarios as you considering, covering different use cases in each scenario, taking care of duplicated steps that could be reused by other module.
74+
>You should write as many scenarios as you consider, covering different use cases in each scenario, taking care of duplicated steps that could be reused by other module.
7375
7476
The anatomy of a feature file is:
7577

@@ -110,8 +112,8 @@ or simply run as the CI does:
110112

111113
```shell
112114
$ export GO_VERSION=1.12.7 # exports which GIMME version to use
113-
$ export STACK_VERSION=7.5.0 # exports stack version as runtime
114-
$ export METRICBEAT_VERSION=7.5.0 # exports metricbeat version
115+
$ export STACK_VERSION=7.6.0 # exports stack version as runtime
116+
$ export METRICBEAT_VERSION=7.6.0 # exports metricbeat version
115117
$ #export FEATURE=redis # exports which feature to run (default 'all')
116118
$ ./.ci/scripts/functional-test.sh ${GO_VERSION} ${FEATURE}
117119
```
@@ -140,7 +142,7 @@ export OP_QUERY_MAX_ATTEMPTS=${OP_QUERY_MAX_ATTEMPTS:-5}
140142
export OP_RETRY_TIMEOUT=${OP_RETRY_TIMEOUT:-3}
141143
export FORMAT=${FORMAT:-pretty} # valid formats are: pretty, junit
142144
# If you do not pass a '-t moduleName' argument, then all tests will be run
143-
godog --format=${FORMAT} -t redis
145+
go test -v --godog.format=${FORMAT} redis
144146
```
145147

146148
>For environment variables reference affecting the logs, please check out [CLI's docs](../cli/README.md#logging)

e2e/features/apm/helm.feature

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
@helm
2-
@k8s
3-
@apm
41
Feature: The Helm chart is following product recommended configuration for Kubernetes
52

63
Scenario: The APM Server chart will create recommended K8S resources

e2e/features/filebeat/helm.feature

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
@helm
2-
@k8s
3-
@filebeat
41
Feature: The Helm chart is following product recommended configuration for Kubernetes
52

63
Scenario: The Filebeat chart will create recommended K8S resources

e2e/features/metricbeat/apache.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@apache
21
Feature: As a Metricbeat developer I want to check that the Apache module works as expected
32

43
Scenario Outline: Check module is sending metrics to Elasticsearch without errors

e2e/features/metricbeat/helm.feature

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
@helm
2-
@k8s
3-
@metricbeat
41
Feature: The Helm chart is following product recommended configuration for Kubernetes
52

63
Scenario: The Metricbeat chart will create recommended K8S resources

e2e/features/metricbeat/metricbeat.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@metricbeat
21
Feature: As a Metricbeat developer I want to check that default configuration works as expected
32

43
Scenario Outline: Check <configuration> configuration is sending metrics to Elasticsearch without errors

e2e/features/metricbeat/mysql.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@mysql
21
Feature: As a Metricbeat developer I want to check that the MySQL module works as expected
32

43
Scenario Outline: Check module is sending metrics to Elasticsearch without errors

e2e/features/metricbeat/vsphere.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@vsphere
21
Feature: As a Metricbeat developer I want to check that the vSphere module works as expected
32

43
Scenario Outline: Check module is sending metrics to Elasticsearch without errors

0 commit comments

Comments
 (0)