-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd42ae3
commit 9a584bb
Showing
18 changed files
with
2,357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
tab_width = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
\*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
|
||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
|
||
coverage | ||
\*.lcov | ||
|
||
# nyc test coverage | ||
|
||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
|
||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
|
||
bower_components | ||
|
||
# node-waf configuration | ||
|
||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
\*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
|
||
.stylelintcache | ||
|
||
# Microbundle cache | ||
|
||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
\*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
|
||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
|
||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
|
||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
|
||
.cache/ | ||
|
||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
|
||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
|
||
# public | ||
|
||
# vuepress build output | ||
|
||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
|
||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
|
||
.docusaurus | ||
|
||
# Serverless directories | ||
|
||
.serverless/ | ||
|
||
# FuseBox cache | ||
|
||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
|
||
.dynamodb/ | ||
|
||
# TernJS port file | ||
|
||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
|
||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.\* | ||
|
||
# wrangler project | ||
|
||
.dev.vars | ||
.wrangler/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 140, | ||
"singleQuote": true, | ||
"semi": true, | ||
"useTabs": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM node | ||
WORKDIR /app | ||
|
||
COPY package.json package-lock.json* ./ | ||
RUN npm i | ||
|
||
COPY src ./src | ||
COPY test ./test | ||
COPY wrangler.toml . | ||
COPY tsconfig.json . | ||
COPY schema.sql . | ||
|
||
RUN npx wrangler d1 execute testing-cloudflare-workers --local --file=./schema.sql | ||
|
||
CMD ["npm", "run", "docker"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Testing Cloudflare Workers with Tracetest and OpenTelemetry | ||
|
||
This example is from the article [**Crafting Observable Cloudflare Workers with OpenTelemetry**]() showing how to run integration and staging tests against Cloudflare Workers using [OpenTelemetry](https://opentelemetry.io/) and Tracetest. | ||
|
||
This is a project bootstrapped with [`C3 (create-cloudflare-cli)`](https://developers.cloudflare.com/workers/get-started/guide/#1-create-a-new-worker-project). | ||
|
||
It's using Cloudflare Workers with [OpenTelemetry configured with otel-cf-workers](https://github.com/evanderkoogh/otel-cf-workers). | ||
|
||
## Prerequisites | ||
|
||
- [Tracetest Account](https://app.tracetest.io/) | ||
- [Tracetest Agent API Key](https://docs.tracetest.io/configuration/agent) | ||
- [Tracetest Environment Token](https://docs.tracetest.io/concepts/environment-tokens) | ||
- [Cloudflare Workers Account](https://workers.cloudflare.com/) | ||
- [Cloudflare Database](https://developers.cloudflare.com/d1/get-started/) | ||
|
||
Create D1 | ||
|
||
```bash | ||
npx wrangler d1 create testing-cloudflare-workers | ||
|
||
✅ Successfully created DB 'testing-cloudflare-workers' in region EEUR | ||
Created your database using D1's new storage backend. The new storage backend is not yet recommended for production workloads, but backs up your data via point-in-time | ||
restore. | ||
[[d1_databases]] | ||
binding = "DB" # i.e. available in your Worker on env.DB | ||
database_name = "testing-cloudflare-workers" | ||
database_id = "<your_database_id>" | ||
``` | ||
Configure D1 | ||
```bash | ||
npx wrangler d1 execute testing-cloudflare-workers --local --file=./schema.sql | ||
npx wrangler d1 execute testing-cloudflare-workers --file=./schema.sql | ||
``` | ||
## Getting Started with Docker | ||
0. Set Tracetest Agent API Key in `docker-compose.yaml`, and set Tracetest Environment Token in `test/run.bash`, and `wrangler.toml`. Set the Cloudflare D1 credentials in the `wrangler.toml` as well. | ||
1. Run Docker Compose | ||
```bash | ||
docker compose up -d --build | ||
``` | ||
2. Run Integration Tests | ||
```bash | ||
docker compose run integration-tests | ||
``` | ||
(Optional. Trigger Tracetest Tests via `app.tracetest.io` against `http://cloudflare-worker:8787`) | ||
## Getting Started Locally | ||
0. Set the Cloudflare D1 credentials in the `wrangler.toml` as well. | ||
1. Install Node Packages | ||
```bash | ||
npm i | ||
``` | ||
2. Run Development Server | ||
```bash | ||
npm run dev | ||
``` | ||
3. Start Tracetest Agent | ||
```bash | ||
tracetest start --api-key ttagent_<apikey> | ||
``` | ||
4. Trigger Tracetest Tests via CLI | ||
```bash | ||
tracetest run test -f ./api.pokemon.spec.development.yaml | ||
``` | ||
(Optional. Trigger Tracetest Tests via `app.tracetest.io` against `http://localhost:8787`) | ||
## Learn more | ||
Feel free to check out the [docs](https://docs.tracetest.io/), and join our [Slack Community](https://dub.sh/tracetest-community) for more info! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
version: "3" | ||
|
||
services: | ||
cloudflare-worker: | ||
image: foobar/cloudflare-worker:v1 | ||
build: | ||
context: . | ||
dockerfile: ./Dockerfile | ||
restart: always | ||
ports: | ||
- 8787:8787 | ||
networks: | ||
- tracetest | ||
|
||
tracetest-agent: | ||
image: kubeshop/tracetest-agent:latest | ||
environment: | ||
- TRACETEST_API_KEY=ttagent_<api_key> # Find the Agent API Key here: https://docs.tracetest.io/configuration/agent | ||
ports: | ||
- 4317:4317 | ||
- 4318:4318 | ||
command: ["--mode", "verbose"] | ||
networks: | ||
- tracetest | ||
|
||
integration-tests: | ||
image: foobar/integration-tests:v2 | ||
profiles: | ||
- tests | ||
build: | ||
context: ./ | ||
dockerfile: ./test/Dockerfile | ||
volumes: | ||
- ./test/:/app/test/ | ||
depends_on: | ||
tracetest-agent: | ||
condition: service_started | ||
networks: | ||
- tracetest | ||
|
||
networks: | ||
tracetest: |
Oops, something went wrong.