Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate testing/environment in favor of elastic-package stack #405

Merged
merged 2 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 28 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ feel free to review the script's [README](https://github.com/elastic/integration
```bash
$ go get -u -d github.com/magefile/mage
```
3. Boot up required dependencies:
3. Use the `elastic-package stack up` command to boot up required dependencies:
1. Elasticseach instance:
* Kibana's dependency
2. Kibana instance:
* used to migrate dashboards, if not available, you can skip the generation (`SKIP_KIBANA=true`)

_Hint_. There is dockerized environment in beats (`cd testing/environments`). Boot it up with the following command:
`docker-compose -f snapshot.yml up --force-recreate`.
~~_Hint_. There is dockerized environment in beats (`cd testing/environments`). Boot it up with the following command:
`docker-compose -f snapshot.yml up --force-recreate`.~~ (deprecated)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we should leave this in here, marked as deprecated? I'm wondering if we can just remove this method altogether now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You convinced me to remove the deprecation notice. Fixed.

_Hint_. There is the `elastic-package` cheat sheet available [here](https://github.com/elastic/integrations/blob/master/testing/environments/README.md).

4. Create a new branch for the integration in `integrations` repository (diverge from master).
5. Run the command: `mage ImportBeats` to start the import process (note that the import script assumes the projects checked out in step 2 are at `../{project-name}`).

Expand Down Expand Up @@ -123,7 +125,7 @@ Most of migration work has been done by the `import-beats` script, but there're
interaction.

It may happen that your integration misses a screenshot or an icon, it's a good moment to add missing resources to
Beats/Kibana repositories and re-import the integration (idempotent).
Beats/Kibana repositories and re-import the integration (idempotent).

#### Checklist

Expand Down Expand Up @@ -160,7 +162,7 @@ what's been already fixed, as the script has overridden part of it).
The README template is used to render the final README file including exported fields. The template should be placed
in the `dev/import-beats-resources/<integration-name>/docs/README.md`.

Review the MySQL docs template to see how to use template functions (e.g. `{{fields "dataset-name"}}`).
Review the MySQL docs template to see how to use template functions (e.g. `{{fields "dataset-name"}}`).
If the same dataset name is used in both metrics and logs, please add `-metrics` and `-logs` in the template. For example, `elb` is a dataset for log and also a dataset for metrics. In README.md template, `{{fields "elb_logs"}}` and `{{fields "elb_metrics"}}` are used to separate them.

5. Review fields file and exported fields in docs.
Expand Down Expand Up @@ -264,21 +266,29 @@ what's been already fixed, as the script has overridden part of it).

### Run the whole setup

1. Build `public` directory with package data:
_The `elastic-package stack` provides an enrolled instance of the Elastic Agent. Use that one instead of a local application
if you can run the service (you're integrating with) in the Docker network. The service Docker image can be used for [system
testing](https://github.com/elastic/elastic-package/blob/master/docs/howto/system_testing.md).

1. Build `packages` directory with package data:
```bash
$ mage build
```

2. Start testing environment:

_Run from inside the Integrations repository._

```bash
$ cd testing/environments
$ docker-compose -f snapshot.yml up
$ elastic-package stack up -d -v
```

The command will boot up a docker cluster with Elasticsearch, Kibana and Package Registry. After every time you
rebuild and reload packages (`mage Reload`), all adjustments in packages will be propagated to the registry.
~~The command will boot up a docker cluster with Elasticsearch, Kibana and Package Registry. After every time you
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the strike out presentation and simply rewrite this section with:

  • what does this command do, and
  • what are the elastic-package commands to run for reloading packages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

rebuild and reload packages (`mage Reload`), all adjustments in packages will be propagated to the registry.~~
The `mage Reload` has been natively replaced with `elastic-package`. More information about reloading local changes in
Kibana in the [cheat sheet](https://github.com/elastic/integrations/blob/master/testing/environments/README.md).

3. Verify that your integration is available (in the right version), e.g. MySQL: http://localhost:8080/search?package=mysql (use
3. Verify that your integration is available (in the right version), e.g. MySQL: http://localhost:8080/search?package=mysql (use
`experimental=true` parameter if the package is in experimental version. Alternatively set `release` to `beta` or higher in your
package's `manifest.yml`, if appropriate.)

Expand Down Expand Up @@ -381,9 +391,12 @@ on the business or technical requirements for the entire platform (Elastic Packa

#### Development

1. When you're developing integrations and you'd like to propagate your changes to the package registry,
use `mage Reload` to rebuild and reload the package registry.

1. ~~When you're developing integrations and you'd like to propagate your changes to the package registry,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's helpful to keep the introductory sentence ("when you're developing..."). Just remove all mentions of mage Reload and replace them with the equivalent elastic-stack commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.

use `mage Reload` to rebuild and reload the package registry.~~

The `mage Reload` has been natively replaced with `elastic-package`. More information about reloading local changes in
Kibana in the [cheat sheet](https://github.com/elastic/integrations/blob/master/testing/environments/README.md).

Explanation: it's much faster to rebuild and restart the container with the Package Registry, than work with
mounted volumes.

Expand Down Expand Up @@ -437,7 +450,7 @@ on the business or technical requirements for the entire platform (Elastic Packa
If you notice that fields file (e.g. `package-fields.yml`) doesn't contain any field definitions or it defines root only,
feel free to remove it.

Bad candidate:
Bad candidate:
```yaml
- name: mypackage.mydataset
type: group
Expand Down
13 changes: 0 additions & 13 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,6 @@ func UpdatePackageStorage() error {
return sh.Run("go", args...)
}

func Reload() error {
err := Build()
if err != nil {
return err
}

err = sh.RunV("docker-compose", "-f", "testing/environments/snapshot.yml", "build", "package-registry")
if err != nil {
return err
}
return sh.RunV("docker-compose", "-f", "testing/environments/snapshot.yml", "up", "-d", "package-registry")
}

// Format method formats integrations.
func formatIntegrations() error {
return runElasticPackageOnAllIntegrations(true, "format")
Expand Down
48 changes: 0 additions & 48 deletions testing/environments/7.9.0.yml

This file was deleted.

4 changes: 0 additions & 4 deletions testing/environments/Dockerfile.package-registry

This file was deleted.

57 changes: 43 additions & 14 deletions testing/environments/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
Before using the Package Registry, remember to `mage build` the project to prepare the volume with packages
(`public` directory).
## Deprecation notice

Refresh docker images:
Docker Compose files have been deprecated in favor of the `elastic-package stack` command. The tool can be found in:
https://github.com/elastic/elastic-package . With the current building procedure, you will also find the correct binary
in the `build` directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Personally I don't think this deprecation notice is necessary but I'm okay with keeping it here if you think it's worth it. If we keep it, at what point would you say its okay to remove this altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the deprecation noticed.


```bash
$ docker-compose -f snapshot.yml pull
```
## Cheat sheet: elastic-package

Run docker containers (Elasticsearch, Kibana, Package Registry):
Update already downloaded Docker images:

```bash
$ docker-compose -f snapshot.yml up --force-recreate
```
`elastic-package stack update -v`

Quickly boot up the stack use:

_Run from within the Integrations repository to consider local package sources (expected for package development)._

`elastic-package stack up -d -v`

Take down the stack:

... or with Elastic Agent:
`elastic-package stack down -v`

Advanced: if you need to modify the internal Docker compose definition, edit files in `~/.elastic-package/stack`, but
keep in mind that these files shouldn't be modified and your changes will be reverted once you update the `elastic-package`:
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


```bash
$ docker-compose -f snapshot.yml -f agent.yml up --force-recreate
$tree ~/.elastic-package/stack
/Users/JohnDoe/.elastic-package/stack
├── Dockerfile.package-registry
├── development
├── kibana.config.yml
├── package-registry.config.yml
└── snapshot.yml
```

Use this command to spawn more agents:
## Cheat sheet: reload local changes in Kibana

Rebuild the modified package:

`mage build` (for all packages)

or

```bash
$ docker-compose -f snapshot.yml -f agent.yml up --scale elastic-agent=10 --no-recreate -d
$ cd packages/apache
$ elastic-package build
```

(for single package, in this sample - _Apache_).

Rebuild and restart the package-registry image:

`elastic-package stack up -v -d --services package-registry`

You should see your latest changes in the Kibana UI.
15 changes: 0 additions & 15 deletions testing/environments/agent.yml

This file was deleted.

16 changes: 0 additions & 16 deletions testing/environments/kibana.config.yml

This file was deleted.

5 changes: 0 additions & 5 deletions testing/environments/package-registry.config.yml

This file was deleted.

50 changes: 0 additions & 50 deletions testing/environments/snapshot.yml

This file was deleted.