Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci/scripts/clean-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -euxo pipefail
# Build and test the app using the install and test make goals.
#

readonly VERSION="8.0.0-SNAPSHOT"
readonly VERSION="$(cat $(pwd)/.stack-version)"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation depends on the folder you launch the script, it must be the root of the repo otherwise do not work. There is an alternative but the .stack-version should be moved to the .ci/scripts folder that I am not sure is a good idea.

srcdir=$(dirname "$0")
test -z "$srcdir" && srcdir=.
readonly VERSION="$(cat ${dirname}/.stack-version)"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about that too and, on CI, we usually run all commands from the root dir (BASE_DIR).

Because it's very well located, we can keep it as is, and refactor if needed.


main() {
# refresh docker images
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/fleet-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ set -euxo pipefail
# Run the functional tests for fleets using the functional-test wrapper
#
# Parameters:
# - STACK_VERSION - that's the version of the stack to be tested. Default '8.0.0-SNAPSHOT'.
# - STACK_VERSION - that's the version of the stack to be tested. Default is stored in '.stack-version'.
#

STACK_VERSION=${1:-'8.0.0-SNAPSHOT'}
STACK_VERSION=${1:-"$(cat $(pwd)/.stack-version)"}
SUITE='fleet'

# Exclude the nightly tests in the CI.
Expand Down
10 changes: 6 additions & 4 deletions .ci/scripts/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ set -euxo pipefail
# Parameters:
# - SUITE - that's the suite to be tested. Default '' which means all of them.
# - TAGS - that's the tags to be tested. Default '' which means all of them.
# - STACK_VERSION - that's the version of the stack to be tested. Default '8.0.0-SNAPSHOT'.
# - BEAT_VERSION - that's the version of the metricbeat to be tested. Default '8.0.0-SNAPSHOT'.
# - STACK_VERSION - that's the version of the stack to be tested. Default is stored in '.stack-version'.
# - BEAT_VERSION - that's the version of the metricbeat to be tested. Default is stored in '.stack-version'.
#

BASE_VERSION="$(cat $(pwd)/.stack-version)"

SUITE=${1:-''}
TAGS=${2:-''}
STACK_VERSION=${3:-'8.0.0-SNAPSHOT'}
BEAT_VERSION=${4:-'8.0.0-SNAPSHOT'}
STACK_VERSION=${3:-"${BASE_VERSION}"}
BEAT_VERSION=${4:-"${BASE_VERSION}"}

## Install the required dependencies for the given SUITE
.ci/scripts/install-test-dependencies.sh "${SUITE}"
Expand Down
10 changes: 6 additions & 4 deletions .ci/scripts/metricbeat-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ set -euxo pipefail
# Run the functional tests for metricbeat using the functional-test wrapper
#
# Parameters:
# - STACK_VERSION - that's the version of the stack to be tested. Default '8.0.0-SNAPSHOT'.
# - BEAT_VERSION - that's the version of the metricbeat to be tested. Default '8.0.0-SNAPSHOT'.
# - STACK_VERSION - that's the version of the stack to be tested. Default is stored in '.stack-version'.
# - BEAT_VERSION - that's the version of the metricbeat to be tested. Default is stored in '.stack-version'.
#

STACK_VERSION=${1:-'8.0.0-SNAPSHOT'}
BEAT_VERSION=${2:-'8.0.0-SNAPSHOT'}
BASE_VERSION="$(cat $(pwd)/.stack-version)"

STACK_VERSION=${1:-"${BASE_VERSION}"}
BEAT_VERSION=${2:-"${BASE_VERSION}"}
SUITE='metricbeat'

.ci/scripts/functional-test.sh "${SUITE}" "" "${STACK_VERSION}" "${BEAT_VERSION}"
1 change: 1 addition & 0 deletions .stack-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.0.0-SNAPSHOT
52 changes: 26 additions & 26 deletions e2e/_suites/fleet/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (fts *FleetTestSuite) beforeScenario() {
fts.StandAlone = false
fts.ElasticAgentStopped = false

fts.Version = common.AgentVersion
fts.Version = common.BeatVersion

policy, err := fts.kibanaClient.GetDefaultPolicy(false)
if err != nil {
Expand Down Expand Up @@ -183,8 +183,8 @@ func (fts *FleetTestSuite) theStandaloneAgentIsListedInFleetWithStatus(desiredSt

return theAgentIsListedInFleetWithStatus(desiredStatus, hostname)
}
maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute * 2
exp := common.GetExponentialBackOff(maxTimeout)
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute * 2
exp := utils.GetExponentialBackOff(maxTimeout)

err := backoff.Retry(waitForAgents, exp)
if err != nil {
Expand Down Expand Up @@ -218,7 +218,7 @@ func (fts *FleetTestSuite) anStaleAgentIsDeployedToFleetWithInstaller(image, ver
case "stale":
version = common.AgentStaleVersion
case "latest":
version = common.AgentVersion
version = common.BeatVersion
default:
version = common.AgentStaleVersion
}
Expand All @@ -240,7 +240,7 @@ func (fts *FleetTestSuite) installCerts() error {
log.WithFields(log.Fields{
"installer": agentInstaller,
"version": fts.Version,
"agentVersion": common.AgentVersion,
"agentVersion": common.BeatVersion,
"agentStaleVersion": common.AgentStaleVersion,
}).Error("No installer found")
return errors.New("no installer found")
Expand All @@ -249,7 +249,7 @@ func (fts *FleetTestSuite) installCerts() error {
err := agentInstaller.InstallCertsFn()
if err != nil {
log.WithFields(log.Fields{
"agentVersion": common.AgentVersion,
"agentVersion": common.BeatVersion,
"agentStaleVersion": common.AgentStaleVersion,
"error": err,
"installer": agentInstaller,
Expand All @@ -266,9 +266,9 @@ func (fts *FleetTestSuite) anAgentIsUpgraded(desiredVersion string) error {
case "stale":
desiredVersion = common.AgentStaleVersion
case "latest":
desiredVersion = common.AgentVersion
desiredVersion = common.BeatVersion
default:
desiredVersion = common.AgentVersion
desiredVersion = common.BeatVersion
}

return fts.kibanaClient.UpgradeAgent(fts.Hostname, desiredVersion)
Expand All @@ -279,7 +279,7 @@ func (fts *FleetTestSuite) agentInVersion(version string) error {
case "stale":
version = common.AgentStaleVersion
case "latest":
version = common.AgentVersion
version = common.BeatVersion
}

agentInVersionFn := func() error {
Expand All @@ -300,8 +300,8 @@ func (fts *FleetTestSuite) agentInVersion(version string) error {
return nil
}

maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute * 2
exp := common.GetExponentialBackOff(maxTimeout)
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute * 2
exp := utils.GetExponentialBackOff(maxTimeout)

return backoff.Retry(agentInVersionFn, exp)
}
Expand Down Expand Up @@ -399,7 +399,7 @@ func (fts *FleetTestSuite) processStateChangedOnTheHost(process string, state st
return err
}

utils.Sleep(time.Duration(common.TimeoutFactor) * 10 * time.Second)
utils.Sleep(time.Duration(utils.TimeoutFactor) * 10 * time.Second)

err = installer.SystemctlRun(profile, agentInstaller.Image, serviceName, "start")
if err != nil {
Expand Down Expand Up @@ -441,7 +441,7 @@ func (fts *FleetTestSuite) processStateChangedOnTheHost(process string, state st

containerName := fts.getContainerName(agentInstaller, 1)

return CheckProcessState(fts.deployer, containerName, process, "stopped", 1, common.TimeoutFactor)
return CheckProcessState(fts.deployer, containerName, process, "stopped", 1, utils.TimeoutFactor)
}

func (fts *FleetTestSuite) setup() error {
Expand All @@ -466,10 +466,10 @@ func theAgentIsListedInFleetWithStatus(desiredStatus string, hostname string) er
if err != nil {
return err
}
maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute * 2
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute * 2
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

agentOnlineFn := func() error {
agentID, err := kibanaClient.GetAgentIDByHostname(hostname)
Expand Down Expand Up @@ -563,7 +563,7 @@ func (fts *FleetTestSuite) theHostIsRestarted() error {
}).Error("Could not stop the service")
}

utils.Sleep(time.Duration(common.TimeoutFactor) * 10 * time.Second)
utils.Sleep(time.Duration(utils.TimeoutFactor) * 10 * time.Second)

_, err = shell.Execute(context.Background(), ".", "docker", "start", containerName)
if err != nil {
Expand All @@ -586,10 +586,10 @@ func (fts *FleetTestSuite) systemPackageDashboardsAreListedInFleet() error {
log.Trace("Checking system Package dashboards in Fleet")

dataStreamsCount := 0
maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

countDataStreamsFn := func() error {
dataStreams, err := fts.kibanaClient.GetDataStreams()
Expand Down Expand Up @@ -730,10 +730,10 @@ func theIntegrationIsOperatedInThePolicy(client *kibana.Client, policy kibana.Po
func (fts *FleetTestSuite) theHostNameIsNotShownInTheAdminViewInTheSecurityApp() error {
log.Trace("Checking if the hostname is not shown in the Administration view in the Security App")

maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

agentListedInSecurityFn := func() error {
host, err := fts.kibanaClient.IsAgentListedInSecurityApp(fts.Hostname)
Expand Down Expand Up @@ -770,10 +770,10 @@ func (fts *FleetTestSuite) theHostNameIsNotShownInTheAdminViewInTheSecurityApp()
func (fts *FleetTestSuite) theHostNameIsShownInTheAdminViewInTheSecurityApp(status string) error {
log.Trace("Checking if the hostname is shown in the Admin view in the Security App")

maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

agentListedInSecurityFn := func() error {
matches, err := fts.kibanaClient.IsAgentListedInSecurityAppWithStatus(fts.Hostname, status)
Expand Down Expand Up @@ -825,10 +825,10 @@ func (fts *FleetTestSuite) thePolicyResponseWillBeShownInTheSecurityApp() error
return err
}

maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

getEventsFn := func() error {
listed, err := fts.kibanaClient.IsPolicyResponseListedInSecurityApp(agentID)
Expand Down Expand Up @@ -924,10 +924,10 @@ func (fts *FleetTestSuite) thePolicyWillReflectTheChangeInTheSecurityApp() error
return err
}

maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute * 2
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute * 2
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

getEventsFn := func() error {
err := fts.kibanaClient.GetAgentEvents("endpoint-security", agentID, pkgPolicy.ID, fts.PolicyUpdatedAt)
Expand Down
42 changes: 6 additions & 36 deletions e2e/_suites/fleet/ingest_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,7 @@ func setUpSuite() {
log.Info("Running in Developer mode 💻: runtime dependencies between different test runs will be reused to speed up dev cycle")
}

// check if base version is an alias
v, err := utils.GetElasticArtifactVersion(common.AgentVersionBase)
if err != nil {
log.WithFields(log.Fields{
"error": err,
"version": common.AgentVersionBase,
}).Fatal("Failed to get agent base version, aborting")
}
common.AgentVersionBase = v

common.AgentVersion = shell.GetEnv("BEAT_VERSION", common.AgentVersionBase)

// check if version is an alias
v, err = utils.GetElasticArtifactVersion(common.AgentVersion)
if err != nil {
log.WithFields(log.Fields{
"error": err,
"version": common.AgentVersion,
}).Fatal("Failed to get agent version, aborting")
}
common.AgentVersion = v

common.StackVersion = shell.GetEnv("STACK_VERSION", common.StackVersion)
v, err = utils.GetElasticArtifactVersion(common.StackVersion)
if err != nil {
log.WithFields(log.Fields{
"error": err,
"version": common.StackVersion,
}).Fatal("Failed to get stack version, aborting")
}
common.StackVersion = v
common.InitVersions()

common.KibanaVersion = shell.GetEnv("KIBANA_VERSION", "")
if common.KibanaVersion == "" {
Expand Down Expand Up @@ -119,12 +89,12 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {

if !shell.GetEnvBool("SKIP_PULL") {
images := []string{
"docker.elastic.co/beats/elastic-agent:" + common.AgentVersion,
"docker.elastic.co/beats/elastic-agent-ubi8:" + common.AgentVersion,
"docker.elastic.co/beats/elastic-agent:" + common.BeatVersion,
"docker.elastic.co/beats/elastic-agent-ubi8:" + common.BeatVersion,
"docker.elastic.co/elasticsearch/elasticsearch:" + common.StackVersion,
"docker.elastic.co/kibana/kibana:" + common.KibanaVersion,
"docker.elastic.co/observability-ci/elastic-agent:" + common.AgentVersion,
"docker.elastic.co/observability-ci/elastic-agent-ubi8:" + common.AgentVersion,
"docker.elastic.co/observability-ci/elastic-agent:" + common.BeatVersion,
"docker.elastic.co/observability-ci/elastic-agent-ubi8:" + common.BeatVersion,
"docker.elastic.co/observability-ci/elasticsearch:" + common.StackVersion,
"docker.elastic.co/observability-ci/elasticsearch-ubi8:" + common.StackVersion,
"docker.elastic.co/observability-ci/kibana:" + common.KibanaVersion,
Expand All @@ -146,7 +116,7 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {
return nil
})

imts.Fleet.Version = common.AgentVersionBase
imts.Fleet.Version = common.BeatVersionBase
imts.Fleet.RuntimeDependenciesStartDate = time.Now().UTC()
})

Expand Down
8 changes: 4 additions & 4 deletions e2e/_suites/fleet/stand-alone.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (fts *FleetTestSuite) aStandaloneAgentIsDeployedWithFleetServerModeOnCloud(
}

func (fts *FleetTestSuite) thereIsNewDataInTheIndexFromAgent() error {
maxTimeout := time.Duration(common.TimeoutFactor) * time.Minute * 2
maxTimeout := time.Duration(utils.TimeoutFactor) * time.Minute * 2
minimumHitsCount := 50

result, err := searchAgentData(fts.Hostname, fts.RuntimeDependenciesStartDate, minimumHitsCount, maxTimeout)
Expand Down Expand Up @@ -94,15 +94,15 @@ func (fts *FleetTestSuite) startStandAloneAgent(image string, composeFilename st
fts.StandAlone = true
log.Trace("Deploying an agent to Fleet")

dockerImageTag := common.AgentVersion
dockerImageTag := common.BeatVersion

useCISnapshots := shell.GetEnvBool("BEATS_USE_CI_SNAPSHOTS")
beatsLocalPath := shell.GetEnv("BEATS_LOCAL_PATH", "")
if useCISnapshots || beatsLocalPath != "" {
// load the docker images that were already:
// a. downloaded from the GCP bucket
// b. fetched from the local beats binaries
dockerInstaller := installer.GetElasticAgentInstaller("docker", image, common.AgentVersion)
dockerInstaller := installer.GetElasticAgentInstaller("docker", image, common.BeatVersion)

dockerInstaller.PreInstallFn()

Expand Down Expand Up @@ -159,7 +159,7 @@ func (fts *FleetTestSuite) thePolicyShowsTheDatasourceAdded(packageName string)
maxTimeout := time.Minute
retryCount := 1

exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

configurationIsPresentFn := func() error {
packagePolicy, err := fts.kibanaClient.GetIntegrationFromAgentPolicy(packageName, fts.Policy)
Expand Down
7 changes: 4 additions & 3 deletions e2e/_suites/fleet/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/cenkalti/backoff/v4"
"github.com/elastic/e2e-testing/internal/common"
"github.com/elastic/e2e-testing/internal/deploy"
"github.com/elastic/e2e-testing/internal/utils"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -42,14 +43,14 @@ func (imts *IngestManagerTestSuite) thereAreInstancesOfTheProcessInTheState(ocur
return err
}

return CheckProcessState(imts.Fleet.deployer, containerName, process, state, count, common.TimeoutFactor)
return CheckProcessState(imts.Fleet.deployer, containerName, process, state, count, utils.TimeoutFactor)
}

// CheckProcessState checks if a process is in the desired state in a container
// name of the container for the service:
// we are using the underlying deployer to run the commands in the container/service
func CheckProcessState(deployer deploy.Deployment, service string, process string, state string, occurrences int, timeoutFactor int) error {
timeout := time.Duration(common.TimeoutFactor) * time.Minute
timeout := time.Duration(utils.TimeoutFactor) * time.Minute

err := waitForProcess(deployer, service, process, state, occurrences, timeout)
if err != nil {
Expand All @@ -76,7 +77,7 @@ func CheckProcessState(deployer deploy.Deployment, service string, process strin
// waitForProcess polls a container executing "ps" command until the process is in the desired state (present or not),
// or a timeout happens
func waitForProcess(deployer deploy.Deployment, service string, process string, desiredState string, ocurrences int, maxTimeout time.Duration) error {
exp := common.GetExponentialBackOff(maxTimeout)
exp := utils.GetExponentialBackOff(maxTimeout)

mustBePresent := false
if desiredState == "started" {
Expand Down
Loading