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="7.x-SNAPSHOT"
readonly VERSION="$(cat $(pwd)/.stack-version)"

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:-'7.x-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 '7.x-SNAPSHOT'.
# - BEAT_VERSION - that's the version of the metricbeat to be tested. Default '7.x-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:-'7.x-SNAPSHOT'}
BEAT_VERSION=${4:-'7.x-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:-'7.x-SNAPSHOT'}
BEAT_VERSION=${2:-'7.x-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
18 changes: 13 additions & 5 deletions cli/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"

"github.com/elastic/e2e-testing/cli/config"
"github.com/elastic/e2e-testing/internal/compose"
"github.com/elastic/e2e-testing/internal/deploy"
log "github.com/sirupsen/logrus"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -63,12 +63,16 @@ func buildDeployServiceCommand(srv string) *cobra.Command {
Short: `Deploys a ` + srv + ` service`,
Long: `Deploys a ` + srv + ` service, adding it to a running profile, identified by its name`,
Run: func(cmd *cobra.Command, args []string) {
serviceManager := compose.NewServiceManager()
serviceManager := deploy.NewServiceManager()

env := map[string]string{}
env = config.PutServiceEnvironment(env, srv, versionToRun)

err := serviceManager.AddServicesToCompose(context.Background(), deployToProfile, []string{srv}, env)
err := serviceManager.AddServicesToCompose(
context.Background(),
deploy.NewServiceRequest(deployToProfile),
[]deploy.ServiceRequest{deploy.NewServiceRequest(srv)},
env)
if err != nil {
log.WithFields(log.Fields{
"profile": deployToProfile,
Expand All @@ -85,12 +89,16 @@ func buildUndeployServiceCommand(srv string) *cobra.Command {
Short: `Undeploys a ` + srv + ` service`,
Long: `Undeploys a ` + srv + ` service, removing it from a running profile, identified by its name`,
Run: func(cmd *cobra.Command, args []string) {
serviceManager := compose.NewServiceManager()
serviceManager := deploy.NewServiceManager()

env := map[string]string{}
env = config.PutServiceEnvironment(env, srv, versionToRun)

err := serviceManager.RemoveServicesFromCompose(context.Background(), deployToProfile, []string{srv}, env)
err := serviceManager.RemoveServicesFromCompose(
context.Background(),
deploy.NewServiceRequest(deployToProfile),
[]deploy.ServiceRequest{deploy.NewServiceRequest(srv)},
env)
if err != nil {
log.WithFields(log.Fields{
"profile": deployToProfile,
Expand Down
18 changes: 10 additions & 8 deletions cli/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"

"github.com/elastic/e2e-testing/cli/config"
"github.com/elastic/e2e-testing/internal/compose"
"github.com/elastic/e2e-testing/internal/deploy"
log "github.com/sirupsen/logrus"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -64,7 +64,7 @@ func buildRunServiceCommand(srv string) *cobra.Command {
Short: `Runs a ` + srv + ` service`,
Long: `Runs a ` + srv + ` service, spinning up a Docker container for it and exposing its internal configuration so that you are able to connect to it in an easy manner`,
Run: func(cmd *cobra.Command, args []string) {
serviceManager := compose.NewServiceManager()
serviceManager := deploy.NewServiceManager()

env := config.PutServiceEnvironment(map[string]string{}, srv, versionToRun)

Expand All @@ -76,7 +76,8 @@ func buildRunServiceCommand(srv string) *cobra.Command {
env[k] = v
}

err := serviceManager.RunCompose(context.Background(), false, []string{srv}, env)
err := serviceManager.RunCompose(
context.Background(), false, []deploy.ServiceRequest{deploy.NewServiceRequest(srv)}, env)
if err != nil {
log.WithFields(log.Fields{
"service": srv,
Expand All @@ -96,7 +97,7 @@ Example:
go run main.go run profile fleet -s elastic-agent:8.0.0-SNAPSHOT
`,
Run: func(cmd *cobra.Command, args []string) {
serviceManager := compose.NewServiceManager()
serviceManager := deploy.NewServiceManager()

env := map[string]string{
"profileVersion": versionToRun,
Expand All @@ -110,14 +111,15 @@ Example:
env[k] = v
}

err := serviceManager.RunCompose(context.Background(), true, []string{key}, env)
err := serviceManager.RunCompose(
context.Background(), true, []deploy.ServiceRequest{deploy.NewServiceRequest(key)}, env)
if err != nil {
log.WithFields(log.Fields{
"profile": key,
}).Error("Could not run the profile.")
}

composeNames := []string{}
composeNames := []deploy.ServiceRequest{}
if len(servicesToRun) > 0 {
for _, srv := range servicesToRun {
arr := strings.Split(srv, ":")
Expand All @@ -137,10 +139,10 @@ Example:
}).Trace("Adding service")

env = config.PutServiceEnvironment(env, image, tag)
composeNames = append(composeNames, image)
composeNames = append(composeNames, deploy.NewServiceRequest(image))
}

err = serviceManager.AddServicesToCompose(context.Background(), key, composeNames, env)
err = serviceManager.AddServicesToCompose(context.Background(), deploy.NewServiceRequest(key), composeNames, env)
if err != nil {
log.WithFields(log.Fields{
"profile": key,
Expand Down
12 changes: 7 additions & 5 deletions cli/cmd/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"

"github.com/elastic/e2e-testing/cli/config"
"github.com/elastic/e2e-testing/internal/compose"
"github.com/elastic/e2e-testing/internal/deploy"
log "github.com/sirupsen/logrus"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -55,9 +55,10 @@ func buildStopServiceCommand(srv string) *cobra.Command {
Short: `Stops a ` + srv + ` service`,
Long: `Stops a ` + srv + ` service, stoppping its Docker container`,
Run: func(cmd *cobra.Command, args []string) {
serviceManager := compose.NewServiceManager()
serviceManager := deploy.NewServiceManager()

err := serviceManager.StopCompose(context.Background(), false, []string{srv})
err := serviceManager.StopCompose(
context.Background(), false, []deploy.ServiceRequest{deploy.NewServiceRequest(srv)})
if err != nil {
log.WithFields(log.Fields{
"service": srv,
Expand All @@ -73,9 +74,10 @@ func buildStopProfileCommand(key string, profile config.Profile) *cobra.Command
Short: `Stops the ` + profile.Name + ` profile`,
Long: `Stops the ` + profile.Name + ` profile, stopping the Services that compound it`,
Run: func(cmd *cobra.Command, args []string) {
serviceManager := compose.NewServiceManager()
serviceManager := deploy.NewServiceManager()

err := serviceManager.StopCompose(context.Background(), true, []string{key})
err := serviceManager.StopCompose(
context.Background(), true, []deploy.ServiceRequest{deploy.NewServiceRequest(key)})
if err != nil {
log.WithFields(log.Fields{
"profile": key,
Expand Down
2 changes: 1 addition & 1 deletion cli/config/compose/profiles/fleet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
test: "curl -f http://localhost:5601/login | grep kbn-injected-metadata 2>&1 >/dev/null"
retries: 600
interval: 1s
image: "docker.elastic.co/${kibanaDockerNamespace:-beats}/kibana:${kibanaVersion:-7.x-SNAPSHOT}"
image: "docker.elastic.co/${kibanaDockerNamespace:-kibana}/kibana:${kibanaVersion:-7.x-SNAPSHOT}"
ports:
- "5601:5601"
volumes:
Expand Down
6 changes: 0 additions & 6 deletions cli/config/compose/services/centos/docker-compose.yml

This file was deleted.

6 changes: 0 additions & 6 deletions cli/config/compose/services/debian/docker-compose.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '2.4'
services:
centos-systemd:
elastic-agent:
image: centos/systemd:${centos_systemdTag:-latest}
container_name: ${centos_systemdContainerName}
entrypoint: "/usr/sbin/init"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: '2.4'
services:
debian-systemd:
elastic-agent:
image: alehaa/debian-systemd:${debian_systemdTag:-stretch}
container_name: ${debian_systemdContainerName}
entrypoint: "/sbin/init"
Expand Down
8 changes: 3 additions & 5 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,14 @@ func FileExists(configFile string) (bool, error) {

// GetComposeFile returns the path of the compose file, looking up the
// tool's workdir
func GetComposeFile(isProfile bool, composeName string, composeFileName ...string) (string, error) {
if isProfile || composeFileName == nil || composeFileName[0] == "" {
composeFileName = []string{"docker-compose.yml"}
}
func GetComposeFile(isProfile bool, composeName string) (string, error) {
composeFileName := "docker-compose.yml"
serviceType := "services"
if isProfile {
serviceType = "profiles"
}

composeFilePath := path.Join(Op.Workspace, "compose", serviceType, composeName, composeFileName[0])
composeFilePath := path.Join(Op.Workspace, "compose", serviceType, composeName, composeFileName)
found, err := io.Exists(composeFilePath)
if found && err == nil {
log.WithFields(log.Fields{
Expand Down
25 changes: 25 additions & 0 deletions cli/config/kubernetes/overlays/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: elastic-agent
labels:
app: elastic-agent
spec:
replicas: 1
selector:
matchLabels:
app: elastic-agent
template:
metadata:
labels:
app: elastic-agent
spec:
containers:
- name: elastic-agent
image: centos/systemd:latest
command: ["/usr/sbin/init"]
securityContext:
allowPrivilegeEscalation: true
runAsUser: 0
capabilities:
add: ["SYS_ADMIN"]
5 changes: 5 additions & 0 deletions cli/config/kubernetes/overlays/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bases:
- ../../base

resources:
- deployment.yaml
18 changes: 9 additions & 9 deletions e2e/_suites/fleet/features/backend_processes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Feature: Backend Processes
Scenario Outline: Deploying the <os> agent
Given a "<os>" agent is deployed to Fleet with "tar" installer
When the "elastic-agent" process is in the "started" state on the host
Then there are "1" instances of the "filebeat" process in the "started" state
And there are "1" instances of the "metricbeat" process in the "started" state
Then there are "2" instances of the "filebeat" process in the "started" state
And there are "2" instances of the "metricbeat" process in the "started" state

@centos
Examples: Centos
Expand All @@ -21,10 +21,10 @@ Examples: Debian

@enroll
Scenario Outline: Deploying the <os> agent with enroll and then run on rpm and deb
Given a "<os>" agent is deployed to Fleet with "systemd" installer
Given a "<os>" agent is deployed to Fleet
When the "elastic-agent" process is in the "started" state on the host
Then there are "1" instances of the "filebeat" process in the "started" state
And there are "1" instances of the "metricbeat" process in the "started" state
Then there are "2" instances of the "filebeat" process in the "started" state
And there are "2" instances of the "metricbeat" process in the "started" state

@centos
Examples: Centos
Expand Down Expand Up @@ -57,8 +57,8 @@ Examples: Debian
Scenario Outline: Restarting the installed <os> agent
Given a "<os>" agent is deployed to Fleet with "tar" installer
When the "elastic-agent" process is "restarted" on the host
Then there are "1" instances of the "filebeat" process in the "started" state
And there are "1" instances of the "metricbeat" process in the "started" state
Then there are "2" instances of the "filebeat" process in the "started" state
And there are "2" instances of the "metricbeat" process in the "started" state

@centos
Examples: Centos
Expand All @@ -75,8 +75,8 @@ Scenario Outline: Restarting the <os> host with persistent agent restarts backen
Given a "<os>" agent is deployed to Fleet with "tar" installer
When the host is restarted
Then the "elastic-agent" process is in the "started" state on the host
And there are "1" instances of the "filebeat" process in the "started" state
And there are "1" instances of the "metricbeat" process in the "started" state
And there are "2" instances of the "filebeat" process in the "started" state
And there are "2" instances of the "metricbeat" process in the "started" state

@centos
Examples: Centos
Expand Down
2 changes: 1 addition & 1 deletion e2e/_suites/fleet/features/fleet_mode_agent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Examples: Debian

@enroll
Scenario Outline: Deploying the <os> agent with enroll and then run on rpm and deb
Given a "<os>" agent is deployed to Fleet with "systemd" installer
Given a "<os>" agent is deployed to Fleet
When the "elastic-agent" process is in the "started" state on the host
Then the agent is listed in Fleet as "online"
And system package dashboards are listed in Fleet
Expand Down
Loading