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

Make Examples runnable in heartbeat / docker #98

Merged
merged 24 commits into from
Oct 27, 2020
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
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ RUN cd /usr/share/heartbeat/.node \\
&& mkdir node \\
&& curl https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz | tar -xJ --strip 1 -C node
ENV PATH="/usr/share/heartbeat/.node/node/bin:$PATH"
# Install playwright first since it speeds up the install of elastic-synthetics*.tgz, since it doesn't need to re-download the
# browsers every time the code there changes
RUN npm i -g playwright
COPY elastic-synthetics*.tgz /opt/elastic-synthetics.tgz
COPY elastic-synthetics-*.tgz /opt/elastic-synthetics.tgz
RUN npm install -g /opt/elastic-synthetics.tgz
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# synthetic-monitoring
Synthetic Monitoring with Real Browsers
# Experimental Synthetics Agent

Synthetic Monitoring with Real Browsers.
**Please note this is an unsupported experimental project. Expect things to break and change!**

## Development
Docs are forthcoming, feel free to browse the repository, but we ask that you refrain from asking questions about use till docs
are published.

Build the main package: `npm run build`

Run: `node dist/cli.js -s '{"homepage":"https://cloud.elastic.co"}' examples/inline/sample-inline-journey.js`
If you'd like to stay informed about synthetic monitoring development please visit [our synthetic monitoring page](https://www.elastic.co/what-is/synthetic-monitoring) where you can sign up to be notified of our initial release.

## CI

Expand Down
2 changes: 2 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh
set -e
set -x
STACK_VERSION=${1:-7.10.0}
echo "Building docker image based on ${STACK_VERSION}..."
npm i
Expand Down
2 changes: 1 addition & 1 deletion examples/docker/bash-build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Build a local docker image using the latest source in this repo
# and run a bash prompty on the container
pushd ../../
./build-docker.sh
./build-docker.sh $1
popd
./bash.sh heartbeat-synthetics-local
6 changes: 2 additions & 4 deletions examples/docker/bash.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/sh
#!/bin/bash
VERSION=${1:-7.10.0}
if [[ version =~ ^[0-9] ]]; then
IMAGE=docker.elastic.co/observability-ci/synthetics:master-$VERSION-synthetics
IMAGE=docker.elastic.co/experimental/synthetics:$VERSION-synthetics
else
IMAGE=$VERSION
fi
Expand All @@ -15,7 +14,6 @@ docker run \
--net=host \
--security-opt seccomp=seccomp_profile.json \
--volume="$(pwd)/heartbeat.docker.yml:/usr/share/heartbeat/heartbeat.yml:ro" \
--volume="$(pwd)/../sample-app/journeys:/opt/sample-app:ro" \
--volume="$(pwd)/../elastic-docs:/opt/elastic-docs:ro" \
--volume="$(pwd)/../:/opt/examples:ro" \
$IMAGE \
bash
7 changes: 2 additions & 5 deletions examples/docker/heartbeat.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ heartbeat.config.monitors:
reload.period: 5s

heartbeat.synthetic_suites:
- name: Sample app
path: "/opt/sample-app"
schedule: "@every 1m"
- name: Docs Suite
path: "/opt/elastic-docs"
- name: Todos
path: "/opt/examples/todos"
schedule: "@every 1m"

processors:
Expand Down
6 changes: 2 additions & 4 deletions examples/docker/pull-latest.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/sh
docker pull docker.elastic.co/observability-ci/synthetics:master-7.10.0-synthetics
docker pull docker.elastic.co/observability-ci/synthetics:master-8.0.0-synthetics
docker pull docker.elastic.co/observability-ci/heartbeat:7.10.0-synthetics
docker pull docker.elastic.co/observability-ci/heartbeat:8.0.0-synthetics
docker pull docker.elastic.co/experimental/synthetics:7.10.0-synthetics
docker pull docker.elastic.co/experimental/synthetics:8.0.0-synthetics
2 changes: 1 addition & 1 deletion examples/docker/run-build-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# Build a local docker image using the latest source in this repo
# and run heartbeat with the config in this directory
pushd ../../
./build-docker.sh
./build-docker.sh $1
popd
./run.sh heartbeat-synthetics-local
26 changes: 18 additions & 8 deletions examples/docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
#!/bin/bash
set -e
set -x
VERSION=${1:-7.10.0}
if [[ version =~ ^[0-9] ]]; then
IMAGE=docker.elastic.co/observability-ci/synthetics:master-$VERSION-synthetics
shift # discard first arg
HEARTBEAT_ARGS=$@

if [ -z $1 ]; then
vigneshshanmugam marked this conversation as resolved.
Show resolved Hide resolved
HEARTBEAT_ARGS="-E output.elasticsearch.hosts=["localhost:9200"] -E output.elasticsearch.username=elastic -E output.elasticsearch.password=changeme"
else
HEARTBEAT_ARGS = $@
fi

# Set Image based on version
if [[ $VERSION =~ ^[0-9] ]]; then
IMAGE=docker.elastic.co/experimental/synthetics:$VERSION-synthetics
else
IMAGE=$VERSION
fi
echo "Using image $IMAGE"

echo "Using image '$IMAGE' with extra args: $HEARTBEAT_ARGS"
docker run \
--rm \
--name=heartbeat \
--user=heartbeat \
--net=host \
--security-opt seccomp=seccomp_profile.json \
--volume="$(pwd)/heartbeat.docker.yml:/usr/share/heartbeat/heartbeat.yml:ro" \
--volume="$(pwd)/../sample-app/journeys:/opt/sample-app:ro" \
--volume="$(pwd)/../elastic-docs:/opt/elastic-docs:ro" \
--volume="$(pwd)/../:/opt/examples:ro" \
$IMAGE \
--strict.perms=false -e \
-E output.elasticsearch.hosts=["localhost:9200"] \
-E output.elasticsearch.username=elastic \
-E output.elasticsearch.password=changeme \
$HEARTBEAT_ARGS
23 changes: 0 additions & 23 deletions examples/elastic-docs/basic.journey.ts

This file was deleted.

14 changes: 0 additions & 14 deletions examples/elastic-docs/cloud_docs.journey.ts

This file was deleted.

13 changes: 0 additions & 13 deletions examples/elastic-docs/common.ts

This file was deleted.

27 changes: 0 additions & 27 deletions examples/sample-app/app.rb

This file was deleted.

53 changes: 0 additions & 53 deletions examples/sample-app/journeys/test-journey.ts

This file was deleted.

16 changes: 0 additions & 16 deletions examples/sample-app/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions examples/sample-app/run_journeys.sh

This file was deleted.

77 changes: 0 additions & 77 deletions examples/sample-app/src/index.ts

This file was deleted.

5 changes: 0 additions & 5 deletions examples/sample-app/start_service.sh

This file was deleted.

20 changes: 0 additions & 20 deletions examples/suites/long.journey.js

This file was deleted.

Loading