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
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: "kibana"
username: "elastic"
password: "changeme"
output.elasticsearch:
hosts: ["http://elasticsearch:9200"]
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: "elasticsearch"
username: "elastic"
password: "changeme"
kibana:
fleet:
host: "kibana"
username: "elastic"
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:
- "${apmVolume}:/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"
22 changes: 13 additions & 9 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 isProfile || composeFileName == nil || composeFileName[0] == "" {
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 Expand Up @@ -130,25 +132,27 @@ func Init() {
}
shell.CheckInstalledSoftware(binaries...)

InitConfig()
initConfig()
}

// InitConfig initialises configuration
func InitConfig() {
// initConfig initialises configuration
func initConfig() {
if Op != nil {
return
}
newConfig(OpDir())
}

// OpDir returns the directory to copy to
func OpDir() string {
home, err := homedir.Dir()
if err != nil {
log.WithFields(log.Fields{
"error": err,
}).Fatal("Could not get current user's HOME dir")
}

w := filepath.Join(home, ".op")

newConfig(w)
return filepath.Join(home, ".op")
}

// PutServiceEnvironment puts the environment variables for the service, replacing "SERVICE_"
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 |
118 changes: 63 additions & 55 deletions e2e/_suites/fleet/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"context"
"fmt"
"github.com/google/uuid"
"strings"
"time"

Expand All @@ -20,7 +21,6 @@ import (
"github.com/elastic/e2e-testing/internal/kibana"
"github.com/elastic/e2e-testing/internal/shell"
"github.com/elastic/e2e-testing/internal/utils"
"github.com/google/uuid"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -98,26 +98,7 @@ func (fts *FleetTestSuite) afterScenario() {
}).Warn("The enrollment token could not be deleted")
}

// Cleanup all package policies
packagePolicies, err := fts.kibanaClient.ListPackagePolicies()
if err != nil {
log.WithFields(log.Fields{
"err": err,
"policy": fts.FleetServerPolicy,
}).Error("The package policies could not be found")
}
for _, pkgPolicy := range packagePolicies {
// Do not remove the fleet server package integration otherwise fleet server fails to bootstrap
if !strings.Contains(pkgPolicy.Name, "fleet_server") && pkgPolicy.PolicyID == fts.FleetServerPolicy.ID {
err = fts.kibanaClient.DeleteIntegrationFromPolicy(pkgPolicy)
if err != nil {
log.WithFields(log.Fields{
"err": err,
"packagePolicy": pkgPolicy,
}).Error("The integration could not be deleted from the configuration")
}
}
}
fts.kibanaClient.DeleteAllPolicies(fts.FleetServerPolicy)

// clean up fields
fts.CurrentTokenID = ""
Expand Down Expand Up @@ -685,8 +666,12 @@ func (fts *FleetTestSuite) theEnrollmentTokenIsRevoked() error {
}

func (fts *FleetTestSuite) thePolicyShowsTheDatasourceAdded(packageName string) error {
return thePolicyShowsTheDatasourceAdded(fts.kibanaClient, fts.FleetServerPolicy, packageName)
}

func thePolicyShowsTheDatasourceAdded(client *kibana.Client, policy kibana.Policy, packageName string) error {
log.WithFields(log.Fields{
"policyID": fts.FleetServerPolicy.ID,
"policyID": policy.ID,
"package": packageName,
}).Trace("Checking if the policy shows the package added")

Expand All @@ -696,11 +681,11 @@ func (fts *FleetTestSuite) thePolicyShowsTheDatasourceAdded(packageName string)
exp := common.GetExponentialBackOff(maxTimeout)

configurationIsPresentFn := func() error {
packagePolicy, err := fts.kibanaClient.GetIntegrationFromAgentPolicy(packageName, fts.FleetServerPolicy)
packagePolicy, err := client.GetIntegrationFromAgentPolicy(packageName, policy)
if err != nil {
log.WithFields(log.Fields{
"packagePolicy": packagePolicy,
"policy": fts.FleetServerPolicy,
"policy": policy,
"retry": retryCount,
"error": err,
}).Warn("The integration was not found in the policy")
Expand All @@ -721,13 +706,17 @@ func (fts *FleetTestSuite) thePolicyShowsTheDatasourceAdded(packageName string)
}

func (fts *FleetTestSuite) theIntegrationIsOperatedInThePolicy(packageName string, action string) error {
return theIntegrationIsOperatedInThePolicy(fts.kibanaClient, fts.FleetServerPolicy, packageName, action)
}

func theIntegrationIsOperatedInThePolicy(client *kibana.Client, policy kibana.Policy, packageName string, action string) error {
log.WithFields(log.Fields{
"action": action,
"policy": fts.FleetServerPolicy,
"policy": policy,
"package": packageName,
}).Trace("Doing an operation for a package on a policy")

integration, err := fts.kibanaClient.GetIntegrationByPackageName(packageName)
integration, err := client.GetIntegrationByPackageName(packageName)
if err != nil {
return err
}
Expand All @@ -737,44 +726,20 @@ func (fts *FleetTestSuite) theIntegrationIsOperatedInThePolicy(packageName strin
Name: integration.Name,
Description: integration.Title,
Namespace: "default",
PolicyID: fts.FleetServerPolicy.ID,
PolicyID: policy.ID,
Enabled: true,
Package: integration,
Inputs: []kibana.Input{},
}
packageDataStream.Inputs = inputs(integration.Name)

if strings.EqualFold(integration.Name, "linux") {
packageDataStream.Inputs = []kibana.Input{
{
Type: "linux/metrics",
Enabled: true,
Streams: []interface{}{
map[string]interface{}{
"id": "linux/metrics-linux.memory-" + uuid.New().String(),
"enabled": true,
"data_stream": map[string]interface{}{
"dataset": "linux.memory",
"type": "metrics",
},
},
},
Vars: map[string]kibana.Var{
"period": {
Value: "1s",
Type: "string",
},
},
},
}
}

return fts.kibanaClient.AddIntegrationToPolicy(packageDataStream)
return client.AddIntegrationToPolicy(packageDataStream)
} else if strings.ToLower(action) == actionREMOVED {
packageDataStream, err := fts.kibanaClient.GetIntegrationFromAgentPolicy(integration.Name, fts.FleetServerPolicy)
packageDataStream, err := client.GetIntegrationFromAgentPolicy(integration.Name, policy)
if err != nil {
return err
}
return fts.kibanaClient.DeleteIntegrationFromPolicy(packageDataStream)
return client.DeleteIntegrationFromPolicy(packageDataStream)
}

return nil
Expand Down Expand Up @@ -1219,3 +1184,46 @@ func deployAgentToFleet(agentInstaller installer.ElasticAgentInstaller, containe

return cfg, agentInstaller.PostInstallFn()
}

func inputs(integration string) []kibana.Input {
switch integration {
case "apm":
return []kibana.Input{
{
Type: "apm",
Enabled: true,
Streams: []interface{}{},
Vars: map[string]kibana.Var{
"apm-server": {
Value: "host",
Type: "localhost:8200",
},
},
},
}
case "linux":
return []kibana.Input{
{
Type: "linux/metrics",
Enabled: true,
Streams: []interface{}{
map[string]interface{}{
"id": "linux/metrics-linux.memory-" + uuid.New().String(),
"enabled": true,
"data_stream": map[string]interface{}{
"dataset": "linux.memory",
"type": "metrics",
},
},
},
Vars: map[string]kibana.Var{
"period": {
Value: "1s",
Type: "string",
},
},
},
}
}
return []kibana.Input{}
}
1 change: 1 addition & 0 deletions e2e/_suites/fleet/ingest_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func InitializeIngestManagerTestSuite(ctx *godog.TestSuiteContext) {
if err != nil {
log.WithFields(log.Fields{
"profile": profile,
"error": err.Error(),
}).Fatal("Could not run the runtime dependencies for the profile.")
}

Expand Down
Loading