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

Commit

Permalink
Merge branch 'master' into remove-volume-stand-alone
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya authored Apr 8, 2021
2 parents b39bd1a + d9e3b51 commit 2a36f11
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 46 deletions.
8 changes: 0 additions & 8 deletions .ci/.package.yaml

This file was deleted.

38 changes: 8 additions & 30 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,17 @@ pipeline {
deleteDir()
unstash 'source'
dir("${BASE_DIR}") {
script {
def matrix = readYaml(file: '.ci/.package.yaml')
def parallelTasks = [:]
matrix['OSS'].each { oss ->
matrix['PLATFORM'].each { platform ->
parallelTasks["${oss}-${platform}"] = generateStep(oss: "${oss}", platform: "${platform}")
}
}
parallel(parallelTasks)
setEnvVar("GITHUB_TOKEN", getGithubToken())
retryWithSleep(retries: 2, seconds: 5, backoff: true) {
sh(label: 'Release binaries with gorelease', script: 'curl -sL https://git.io/goreleaser | bash -s -- --rm-dist', returnStatus: true)
}
}
}
post {
always {
archiveArtifacts allowEmptyArchive: true, artifacts: "${BASE_DIR}/cli/dist/**"
}
}
}
}
}
Expand Down Expand Up @@ -279,27 +278,6 @@ def doNotifyBuildResult(boolean slackNotify) {
notifyBuildResult(analyzeFlakey: true, jobName: getFlakyJobName(withBranch: "${env.JOB_BASE_NAME}"), prComment: true, slackHeader: header, slackChannel: "${channels}", slackComment: true, slackNotify: slackNotify)
}


def generateStep(Map args = [:]){
def oss = args.get('oss')
def platform = args.get('platform')
return {
withNode(labels: 'ubuntu-18.04 && immutable && docker', sleepMax: 20, forceWorkspace: true){
try {
deleteDir()
unstash 'source'
dir("${BASE_DIR}/cli") {
withEnv(["GOOS=${oss}", "GOARCH=${platform}"]) {
sh script: 'make build', label: 'Create releases'
}
}
} finally {
archiveArtifacts allowEmptyArchive: true, artifacts: "${BASE_DIR}/cli/.github/releases/download/**"
}
}
}
}

def generateFunctionalTestStep(Map args = [:]){
def platform = args.get('platform')
def suite = args.get('suite')
Expand Down
27 changes: 27 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,30 @@ changelog:
exclude:
- '^docs:'
- '^test:'

# https://goreleaser.com/customization/release/
release:
# Repo in which the release will be created.
# Default is extracted from the origin remote URL or empty if its private hosted.
# Note: it can only be one: either github, gitlab or gitea
github:
owner: elastic
name: e2e-testing

# If set to true, will not auto-publish the release.
# Default is false.
draft: true

# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: auto

# You can change the name of the release.
# Default is `{{.Tag}}`
name_template: "{{.Tag}}"

# You can disable this pipe in order to not upload any artifacts.
# Defaults to false.
disable: false
12 changes: 12 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ $ ./op run service mysql -v 5.7.12
$ ./op run profile metricbeat
```

To pass in multiple services at once:

```
$ ./op run profile fleet -s elastic-agent:8.0.0-SNAPSHOT -s debian-systemd:latest
```

The tool also provides a way to stop those running services:
```sh
# if you are in the Go development world
Expand All @@ -31,6 +37,12 @@ $ ./op stop service mysql -v 5.7.12
$ ./op stop profile metricbeat
```

Additionally, you can pass in environment options that will be passed along to the docker-compose configurations during deployment through use of the `-e` flag.

```
$ ./op run profile fleet -s elastic-agent:8.0.0-SNAPSHOT -s debian-systemd:latest -e fleetServerMode=1 -e debian_systemdContainerName=test_container_1
```

>By the way, `op` comes from `Observability Provisioner`.
## Configuring the CLI
Expand Down
34 changes: 28 additions & 6 deletions cli/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
"github.com/spf13/cobra"
)

var servicesToRun string
var servicesToRun []string
var versionToRun string
var environmentItems map[string]string

func init() {
config.Init()
Expand All @@ -38,12 +39,14 @@ func init() {
profileSubcommand := buildRunProfileCommand(k, profile)

profileSubcommand.Flags().StringVarP(&versionToRun, "profileVersion", "v", "latest", "Sets the profile version to run")
profileSubcommand.Flags().StringVarP(&servicesToRun, "withServices", "s", "", "Sets a list of comma-separated services to be depoyed alongside the profile")
profileSubcommand.Flags().StringSliceVarP(&servicesToRun, "withServices", "s", nil, "List of services to deploy with profile, in the format of docker <image>:<tag>")
profileSubcommand.Flags().StringToStringVarP(&environmentItems, "environment", "e", nil, "A list of environment key/value pairs to pass into deployment, in the format of ENV=VAR")

runProfileCmd.AddCommand(profileSubcommand)
}

runCmd.AddCommand(runProfileCmd)

}

var runCmd = &cobra.Command{
Expand All @@ -65,6 +68,14 @@ func buildRunServiceCommand(srv string) *cobra.Command {

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

for k, v := range environmentItems {
log.WithFields(log.Fields{
"env": k,
"var": v,
}).Trace("Adding key/value to environment")
env[k] = v
}

err := serviceManager.RunCompose(context.Background(), false, []string{srv}, env)
if err != nil {
log.WithFields(log.Fields{
Expand All @@ -91,6 +102,14 @@ Example:
"profileVersion": versionToRun,
}

for k, v := range environmentItems {
log.WithFields(log.Fields{
"env": k,
"var": v,
}).Trace("Adding key/value to environment")
env[k] = v
}

err := serviceManager.RunCompose(context.Background(), true, []string{key}, env)
if err != nil {
log.WithFields(log.Fields{
Expand All @@ -99,10 +118,8 @@ Example:
}

composeNames := []string{}
if servicesToRun != "" {
services := strings.Split(servicesToRun, ",")

for _, srv := range services {
if len(servicesToRun) > 0 {
for _, srv := range servicesToRun {
arr := strings.Split(srv, ":")
if len(arr) != 2 {
log.WithFields(log.Fields{
Expand All @@ -114,6 +131,11 @@ Example:
image := arr[0]
tag := arr[1]

log.WithFields(log.Fields{
"image": image,
"tag": tag,
}).Trace("Adding service")

env = config.PutServiceEnvironment(env, image, tag)
composeNames = append(composeNames, image)
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/_suites/fleet/features/stand_alone_agent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Examples: Ubi8
@run_fleet_server
Scenario Outline: Deploying a <image> stand-alone agent with fleet server mode
When a "<image>" stand-alone agent is deployed with fleet server mode
Then the agent is listed in Fleet as "online"
Then the stand-alone agent is listed in Fleet as "online"

@default
Examples: default
Expand Down
2 changes: 1 addition & 1 deletion e2e/_suites/fleet/stand-alone.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (sats *StandAloneTestSuite) contributeSteps(s *godog.ScenarioContext) {
s.Step(`^there is new data in the index from agent$`, sats.thereIsNewDataInTheIndexFromAgent)
s.Step(`^the "([^"]*)" docker container is stopped$`, sats.theDockerContainerIsStopped)
s.Step(`^there is no new data in the index after agent shuts down$`, sats.thereIsNoNewDataInTheIndexAfterAgentShutsDown)
s.Step(`^the agent is listed in Fleet as "([^"]*)"$`, sats.theAgentIsListedInFleetWithStatus)
s.Step(`^the stand-alone agent is listed in Fleet as "([^"]*)"$`, sats.theAgentIsListedInFleetWithStatus)
}

func (sats *StandAloneTestSuite) theAgentIsListedInFleetWithStatus(desiredStatus string) error {
Expand Down

0 comments on commit 2a36f11

Please sign in to comment.