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

docs: Update examples developer documentation #13200

Merged
merged 8 commits into from
Oct 6, 2020
Merged
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
79 changes: 78 additions & 1 deletion examples/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ bring_up_example
If your sandbox has multiple compositions, and uses the `$PATHS` env var described above,
`bring_up_example` will bring all of your compositions up.


### Additional arguments to `docker-compose up -d`

If you need to pass additional arguments to compose you can set the `UPARGS`
Expand All @@ -208,3 +207,81 @@ export UPARGS="--scale http_service=2"
If your example asks the user to run commands inside containers, you can
mimick this using `docker-compose exec -T`. The `-T` flag is necessary as the
tests do not have access to a `tty` in the CI pipeline.

### Note on permissions and configuration

The sandbox tests are run with a `umask` setting of `027` to ensure they will run in environments
where this is the case.

As the Envoy containers run as non-root, it is essential that any configurations required
by the daemon are included in the relevant example `Dockerfile` rather than mounted in
any `docker-compose.yaml` files.

The Docker recipe should also ensure that added configurations are world-readable.

For example, with an added configuration file named `front-envoy.yaml`, you should add
the following in the Docker recipe:

```
RUN chmod go+r /etc/front-envoy.yaml
```

## Sandbox configuration tests

Example configuration files are tested to ensure they are valid and well-formed, and do
not contain deprecated features.

### Exclude configs from example configuration tests

The CI script searches for all files in the examples folders with a `yaml` or `lua` extension.

These files are bundled into a test and the `yaml` files are used to try to start an Envoy server.

If your example includes `yaml` files that are either not Envoy configuration, or for some reason
cannot be tested in this way, you should add the files to the `exclude` list in the `filegroup.srcs`
section of the `examples/BUILD` file.

The `exclude` patterns are evaluated as `globs` in the context of the `examples` folder.


## Verifying your sandbox

Once you have built your sandbox, and added the `verify.sh` script you can run it directly in the
sandbox folder.

For example:

```
cd examples/example-sandbox
./verify.sh
```

You should see the docker composition brought up, your tests run, and the composition brought down again.

The script should exit with `0` for the tests to pass.


## Verifying multiple/all sandboxes

In continuous integration, all of the sandboxes are checked using the `ci/verify-examples.sh`.

This can also be called with a filter argument, which is a `glob` evaluated in the context of the `examples` folder.

For example, to run all sandboxes with names beginning `jaeger`:

```
./ci/verify-examples.sh jaeger*
```

---

**NOTE**

You can use this script locally to test the sandboxes on your platform, but you should be aware that it requires
a lot of resources as it downloads and builds many Docker images, and then runs them in turn.

---

One way to run the tests in an isolated environment is to mount the `envoy` source into a `docker-in-docker` container
Copy link
Member Author

Choose a reason for hiding this comment

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

this could do with being expanded upon in some way, but i would rather not do it in this pr

my way of doing this is a little involved - so it would be easier to think about after

i would have added a todo but its not easy/possible in markdown

or similar, and then run the script from inside that container.