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

Commit fee7463

Browse files
authored
Merge pull request #108 from mdelapenya/103-fix-metricbeat-tests
Fix metricbeat tests
2 parents 9348b71 + c7f1f71 commit fee7463

20 files changed

Lines changed: 292 additions & 118 deletions

.ci/.e2e-tests.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
FEATURES:
33
- "apache"
44
- "helm"
5+
- "metricbeat"
56
- "mysql"
67
- "redis"

.ci/Jenkinsfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pipeline {
2525
}
2626
parameters {
2727
choice(name: 'LOG_LEVEL', choices: ['INFO', 'DEBUG'], description: 'Log level to be used')
28+
choice(name: 'QUERY_MAX_ATTEMPTS', choices: ['5', '10', '20'], description: 'Number of attempts to create the connection to Elasticsearch')
29+
choice(name: 'RETRY_TIMEOUT', choices: ['3', '5', '7', '11'], description: 'Number of seconds between retry')
2830
string(name: 'STACK_VERSION', defaultValue: '7.6.0', description: 'SemVer version of the stack to be used.')
2931
string(name: 'METRICBEAT_VERSION', defaultValue: '7.6.0', description: 'SemVer version of the metricbeat to be used.')
3032
string(name: 'HELM_CHART_VERSION', defaultValue: '7.6.1', description: 'SemVer version of Helm chart to be used.')
@@ -51,6 +53,8 @@ pipeline {
5153
KIND_VERSION = "${params.KIND_VERSION.trim()}"
5254
KUBERNETES_VERSION = "${params.KUBERNETES_VERSION.trim()}"
5355
LOG_LEVEL = "${params.LOG_LEVEL.trim()}"
56+
QUERY_MAX_ATTEMPTS = "${params.QUERY_MAX_ATTEMPTS.trim()}"
57+
RETRY_TIMEOUT = "${params.RETRY_TIMEOUT.trim()}"
5458
}
5559
stages {
5660
stage('Checkout') {
@@ -183,6 +187,11 @@ def generateFunctionalTestStep(Map params = [:]){
183187
try {
184188
deleteDir()
185189
unstash 'build'
190+
retry(3){
191+
dir("${BASE_DIR}"){
192+
sh script: """.ci/scripts/install-test-dependencies.sh "${GO_VERSION}" """, label: "Install test dependencies for ${feature}"
193+
}
194+
}
186195
dir("${BASE_DIR}"){
187196
sh script: """.ci/scripts/functional-test.sh "${GO_VERSION}" "${feature}" "${STACK_VERSION}" "${METRICBEAT_VERSION}" """, label: "Run functional tests for ${feature}"
188197
}

.ci/functionalTests.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ pipeline {
107107
steps {
108108
deleteDir()
109109
unstash 'source'
110+
retry(3){
111+
dir("${BASE_DIR}"){
112+
sh script: """.ci/scripts/install-test-dependencies.sh "${GO_VERSION}" """, label: "Install test dependencies for ${params.FEATURE}"
113+
}
114+
}
110115
dir(BASE_DIR){
111116
sh script: """.ci/scripts/functional-test.sh "${GO_VERSION}" "${params.FEATURE}" """, label: 'Run functional tests'
112117
}

.ci/scripts/functional-test.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ TARGET_ARCH=${GOARCH:-amd64}
1919
# shellcheck disable=SC1091
2020
source .ci/scripts/install-go.sh "${GO_VERSION}"
2121

22-
# shellcheck disable=SC1091
23-
source .ci/scripts/install-test-dependencies.sh
24-
2522
# Build OP Binary
2623
GOOS=${TARGET_OS} GOARCH=${TARGET_ARCH} make -C e2e fetch-binary
2724

28-
# Build runtime dependencies
29-
STACK_VERSION=${STACK_VERSION} make -C e2e run-elastic-stack
30-
3125
# Sync integrations
3226
make -C e2e sync-integrations
3327

.ci/scripts/install-test-dependencies.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ set -euxo pipefail
44
# Install the dependencies using the install and test make goals.
55
#
66
# Parameters:
7+
# - GO_VERSION - that's the Go version which will be used for running Go code.
78
# - HELM_VERSION - that's the Helm version which will be installed and enabled.
89
# - KIND_VERSION - that's the Kind version which will be installed and enabled.
910
# - KUBERNETES_VERSION - that's the Kubernetes version which will be installed and enabled.
1011
#
1112

13+
GO_VERSION=${1:?GO_VERSION is not set}
14+
15+
# shellcheck disable=SC1091
16+
source .ci/scripts/install-go.sh "${GO_VERSION}"
17+
1218
MSG="parameter missing."
1319
HOME=${HOME:?$MSG}
1420

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@
102102
"type": "go",
103103
"request": "launch",
104104
"mode": "auto",
105-
"program": "${workspaceFolder}/e2e",
105+
"program": "${file}",
106106
"env": {
107107
"GO111MODULE": "on",
108108
"OP_LOG_LEVEL": "DEBUG",
109109
},
110-
"args": ["godog", "-t", "mysql"]
110+
"args": ["--godog.format", "pretty", "metricbeat"]
111111
}
112112
]
113113
}

cli/config/compose/services/metricbeat/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ services:
33
metricbeat:
44
command: [
55
"metricbeat", "-e",
6+
"-E", "logging.level=${logLevel}",
67
"-E", "setup.ilm.rollover_alias=${indexName}",
78
"-E", "output.elasticsearch.hosts=http://elasticsearch:9200",
89
"-E", "output.elasticsearch.password=p4ssw0rd",

cli/config/compose/stacks/metricbeat/docker-compose.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,3 @@ services:
1212
image: "docker.elastic.co/elasticsearch/elasticsearch:${stackVersion}"
1313
ports:
1414
- "9200:9200"
15-
kibana:
16-
environment:
17-
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
18-
- ELASTIC_USERNAME=elastic
19-
- ELASTIC_PASSWORD=p4ssw0rd
20-
image: "docker.elastic.co/kibana/kibana:${stackVersion}"
21-
ports:
22-
- "5601:5601"

cli/services/manager.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
type ServiceManager interface {
1616
AddServicesToCompose(stack string, composeNames []string, env map[string]string) error
1717
RemoveServicesFromCompose(stack string, composeNames []string, env map[string]string) error
18+
RunCommand(stack string, composeNames []string, composeArgs []string, env map[string]string) error
1819
RunCompose(isStack bool, composeNames []string, env map[string]string) error
1920
StopCompose(isStack bool, composeNames []string) error
2021
}
@@ -84,6 +85,11 @@ func (sm *DockerServiceManager) RemoveServicesFromCompose(stack string, composeN
8485
return nil
8586
}
8687

88+
// RunCommand executes a docker-compose command in a running a docker compose
89+
func (sm *DockerServiceManager) RunCommand(stack string, composeNames []string, composeArgs []string, env map[string]string) error {
90+
return executeCompose(sm, true, composeNames, composeArgs, env)
91+
}
92+
8793
// RunCompose runs a docker compose by its name
8894
func (sm *DockerServiceManager) RunCompose(isStack bool, composeNames []string, env map[string]string) error {
8995
return executeCompose(sm, isStack, composeNames, []string{"up", "-d"}, env)

e2e/Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ functional-test:
3232
OP_STACK_VERSION=${STACK_VERSION} \
3333
go test -v --godog.format=${FORMAT} ${FEATURE}
3434

35-
.PHONY: run-elastic-stack
36-
run-elastic-stack:
37-
OP_LOG_LEVEL=${LOG_LEVEL} ./op run stack metricbeat -v ${STACK_VERSION}
38-
39-
.PHONY: shutdown-elastic-stack
40-
shutdown-elastic-stack:
41-
OP_LOG_LEVEL=${LOG_LEVEL} ./op stop stack metricbeat
42-
4335
.PHONY: sync-integrations
4436
sync-integrations:
4537
OP_LOG_LEVEL=${LOG_LEVEL} ./op sync integrations --delete

0 commit comments

Comments
 (0)