Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ xpack.fleet.enabled: true
xpack.fleet.registryUrl: http://package-registry:8080
xpack.fleet.agents.enabled: true
xpack.fleet.agents.elasticsearch.host: http://elasticsearch:9200
xpack.fleet.agents.kibana.host: http://kibana:5601
# xpack.fleet.agents.kibana.host: http://kibana:5601
xpack.fleet.agents.tlsCheckDisabled: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
monitoring.enabled: true
http.enabled: true
http.port: 5067
http.host: "0.0.0.0"
apm-server:
host: "0.0.0:8200"
secret_token: "1234"
# Enable APM Server Golang expvar support (https://golang.org/pkg/expvar/).
expvar:
enabled: true
url: "/debug/vars"
kibana:
# For APM Agent configuration in Kibana, enabled must be true.
enabled: true
host: ""
username: "elastic"
password: "changeme"
output.elasticsearch:
hosts: [""]
username: "elastic"
password: "changeme"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
capabilities:
- rule: allow
input: fleet-server
- rule: deny
input: "*"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
fleet_server:
elasticsearch:
host: ""
username: "elastic"
password: "changeme"
kibana:
fleet:
host: ""
username: "admin"
password: "changeme"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fleet:
enroll: true
force: false
insecure: true
fleet_server:
enable: true
kibana:
fleet:
setup: true
26 changes: 26 additions & 0 deletions cli/config/compose/services/elastic-agent/docker-compose-cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '2.4'
services:
elastic-agent:
image: docker.elastic.co/${elasticAgentDockerNamespace:-beats}/elastic-agent${elasticAgentDockerImageSuffix}:${elasticAgentTag:-8.0.0-SNAPSHOT}
container_name: ${elasticAgentContainerName}
depends_on:
elasticsearch:
condition: service_healthy
kibana:
condition: service_healthy
environment:
- "FLEET_SERVER_ENABLE=1"
- "FLEET_SERVER_INSECURE_HTTP=1"
- "ELASTIC_AGENT_CLOUD=1"
- "APM_SERVER_PATH=/apm-legacy/apm-server/"
- "STATE_PATH=/apm-legacy/elastic-agent/"
- "CONFIG_PATH=/apm-legacy/config/"
- "DATA_PATH=/apm-legacy/data/"
- "LOGS_PATH=/apm-legacy/logs/"
- "HOME_PATH=/apm-legacy/"
volumes:
- "./apm-legacy:/apm-legacy"
ports:
- "127.0.0.1:8220:8220"
- "127.0.0.1:8200:8200"
- "127.0.0.1:5066:5066"
4 changes: 0 additions & 4 deletions cli/config/compose/services/elastic-agent/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ services:
kibana:
condition: service_healthy
environment:
- "FLEET_SERVER_ELASTICSEARCH_HOST=http://${elasticsearchHost:-elasticsearch}:${elasticsearchPort:-9200}"
- "FLEET_SERVER_ENABLE=${fleetServerMode:-0}"
- "FLEET_SERVER_INSECURE_HTTP=${fleetServerMode:-0}"
- "FLEET_SERVER_HOST=0.0.0.0"
- "FLEET_SERVER_ELASTICSEARCH_USERNAME=elastic"
- "FLEET_SERVER_ELASTICSEARCH_PASSWORD=changeme"
platform: ${elasticAgentPlatform:-linux/amd64}
ports:
- "127.0.0.1:8220:8220"
8 changes: 5 additions & 3 deletions cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ 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) (string, error) {
composeFileName := "docker-compose.yml"
func GetComposeFile(isProfile bool, composeName string, composeFileName ...string) (string, error) {
if composeFileName == nil || isProfile {
composeFileName = []string{"docker-compose.yml"}
}
serviceType := "services"
if isProfile {
serviceType = "profiles"
}

composeFilePath := path.Join(Op.Workspace, "compose", serviceType, composeName, composeFileName)
composeFilePath := path.Join(Op.Workspace, "compose", serviceType, composeName, composeFileName[0])
found, err := io.Exists(composeFilePath)
if found && err == nil {
log.WithFields(log.Fields{
Expand Down
22 changes: 10 additions & 12 deletions cli/services/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ package services
import (
"context"
"fmt"
"path/filepath"

"github.com/elastic/e2e-testing/cli/config"
state "github.com/elastic/e2e-testing/cli/internal"
"go.elastic.co/apm"
"path/filepath"

log "github.com/sirupsen/logrus"
tc "github.com/testcontainers/testcontainers-go"
)

// ServiceManager manages lifecycle of a service
type ServiceManager interface {
AddServicesToCompose(ctx context.Context, profile string, composeNames []string, env map[string]string) error
AddServicesToCompose(ctx context.Context, profile string, composeNames []string, env map[string]string, composeFilename ...string) error
RemoveServicesFromCompose(ctx context.Context, profile string, composeNames []string, env map[string]string) error
RunCommand(profile string, composeNames []string, composeArgs []string, env map[string]string) error
RunCompose(ctx context.Context, isProfile bool, composeNames []string, env map[string]string) error
Expand All @@ -36,7 +35,7 @@ func NewServiceManager() ServiceManager {
}

// AddServicesToCompose adds services to a running docker compose
func (sm *DockerServiceManager) AddServicesToCompose(ctx context.Context, profile string, composeNames []string, env map[string]string) error {
func (sm *DockerServiceManager) AddServicesToCompose(ctx context.Context, profile string, composeNames []string, env map[string]string, composeFilename ...string) error {
span, _ := apm.StartSpanOptions(ctx, "Add services to Docker Compose", "docker-compose.services.add", apm.SpanOptions{
Parent: apm.SpanFromContext(ctx).TraceContext(),
})
Expand All @@ -55,7 +54,7 @@ func (sm *DockerServiceManager) AddServicesToCompose(ctx context.Context, profil
persistedEnv[k] = v
}

err := executeCompose(sm, true, newComposeNames, []string{"up", "-d"}, persistedEnv)
err := executeCompose(true, newComposeNames, []string{"up", "-d"}, persistedEnv, composeFilename...)
if err != nil {
return err
}
Expand Down Expand Up @@ -87,7 +86,7 @@ func (sm *DockerServiceManager) RemoveServicesFromCompose(ctx context.Context, p
command := []string{"rm", "-fvs"}
command = append(command, composeName)

err := executeCompose(sm, true, newComposeNames, command, persistedEnv)
err := executeCompose(true, newComposeNames, command, persistedEnv)
if err != nil {
log.WithFields(log.Fields{
"command": command,
Expand All @@ -107,7 +106,7 @@ func (sm *DockerServiceManager) RemoveServicesFromCompose(ctx context.Context, p

// RunCommand executes a docker-compose command in a running a docker compose
func (sm *DockerServiceManager) RunCommand(profile string, composeNames []string, composeArgs []string, env map[string]string) error {
return executeCompose(sm, true, composeNames, composeArgs, env)
return executeCompose(true, composeNames, composeArgs, env)
}

// RunCompose runs a docker compose by its name
Expand All @@ -117,7 +116,7 @@ func (sm *DockerServiceManager) RunCompose(ctx context.Context, isProfile bool,
})
defer span.End()

return executeCompose(sm, isProfile, composeNames, []string{"up", "-d"}, env)
return executeCompose(isProfile, composeNames, []string{"up", "-d"}, env)
}

// StopCompose stops a docker compose by its name
Expand Down Expand Up @@ -147,7 +146,7 @@ func (sm *DockerServiceManager) StopCompose(ctx context.Context, isProfile bool,
}
persistedEnv := state.Recover(ID, config.Op.Workspace)

err := executeCompose(sm, isProfile, composeNames, []string{"down", "--remove-orphans"}, persistedEnv)
err := executeCompose(isProfile, composeNames, []string{"down", "--remove-orphans"}, persistedEnv)
if err != nil {
return fmt.Errorf("Could not stop compose file: %v - %v", composeFilePaths, err)
}
Expand All @@ -161,21 +160,20 @@ func (sm *DockerServiceManager) StopCompose(ctx context.Context, isProfile bool,
return nil
}

func executeCompose(sm *DockerServiceManager, isProfile bool, composeNames []string, command []string, env map[string]string) error {
func executeCompose(isProfile bool, composeNames []string, command []string, env map[string]string, composeFilename ...string) error {
composeFilePaths := make([]string, len(composeNames))
for i, composeName := range composeNames {
b := false
if i == 0 && isProfile {
b = true
}

composeFilePath, err := config.GetComposeFile(b, composeName)
composeFilePath, err := config.GetComposeFile(b, composeName, composeFilename...)
if err != nil {
return fmt.Errorf("Could not get compose file: %s - %v", composeFilePath, err)
}
composeFilePaths[i] = composeFilePath
}

compose := tc.NewLocalDockerCompose(composeFilePaths, composeNames[0])
execError := compose.
WithCommand(command).
Expand Down
30 changes: 30 additions & 0 deletions e2e/_suites/fleet/features/apm_integration.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@apm_server
Feature: APM Integration
Scenarios for APM

@install
Scenario Outline: Deploying a <image> stand-alone agent with fleet server mode
Given a "<image>" stand-alone agent is deployed with fleet server mode
And the stand-alone agent is listed in Fleet as "online"
When the "Elastic APM" integration is added to the policy
Then the "Elastic APM" datasource is shown in the policy
And the "apm-server" process is in the "started" state on the host


@default
Examples: default
| image |
| default |



@cloud
Scenario Outline: Deploying a <image> stand-alone agent with fleet server mode on cloud
When a "<image>" stand-alone agent is deployed with fleet server mode on cloud
Then the "apm-server" process is in the "started" state on the host


@default
Examples: default
| image |
| default |
Loading