🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: add web async test setup (#4294)
Max Deichmann9841973b1649
diff --git a/.env.dev.example b/.env.dev.exampleindex 64a8168030..ce09d42075 100644--- a/.env.dev.example+++ b/.env.dev.example@@ -77,4 +77,10 @@ REDIS_AUTH="myredissecret"ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000# speeds up local development by not executing init scripts on server startup-NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT="false"\ No newline at end of file+NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT="false"+++LANGFUSE_READ_FROM_POSTGRES_ONLY=false+LANGFUSE_RETURN_FROM_CLICKHOUSE=true+LANGFUSE_READ_DASHBOARDS_FROM_CLICKHOUSE=true+LANGFUSE_READ_FROM_CLICKHOUSE_ONLY=truediff --git a/.env.dev.legacy.example b/.env.dev.legacy.examplenew file mode 100644index 0000000000..64a8168030--- /dev/null+++ b/.env.dev.legacy.example@@ -0,0 +1,80 @@+# When adding additional environment variables, the schema in "/src/env.mjs"+# should be updated accordingly.++# Prisma+# https://www.prisma.io/docs/reference/database-reference/connection-urls#env+DIRECT_URL="postgresql://postgres:postgres@localhost:5432/postgres"+DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres"++# Clickhouse+CLICKHOUSE_MIGRATION_URL="clickhouse://localhost:9000"+CLICKHOUSE_URL="http://localhost:8123"+CLICKHOUSE_USER="clickhouse"+CLICKHOUSE_PASSWORD="clickhouse"++# Next Auth+# You can generate a new secret on the command line with:+# openssl rand -base64 32+# https://next-auth.js.org/configuration/options#secret+# NEXTAUTH_SECRET=""+NEXTAUTH_URL="http://localhost:3000"+NEXTAUTH_SECRET="secret"++# Langfuse Cloud Environment+NEXT_PUBLIC_LANGFUSE_CLOUD_REGION="DEV"++# Langfuse experimental features+LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES="true"++# Salt for API key hashing+SALT="salt"++EMAIL_FROM_ADDRESS="" # Defines the email address to use as the from address.+SMTP_CONNECTION_URL="" # Defines the connection url for smtp server.++# S3 storage+S3_ENDPOINT=http://localhost:9090+S3_ACCESS_KEY_ID=minio+S3_SECRET_ACCESS_KEY=miniosecret+S3_BUCKET_NAME=langfuse+S3_REGION=us-east-1+## Necessary for minio compatibility+S3_FORCE_PATH_STYLE=true++# # S3 Media Upload LOCAL+LANGFUSE_S3_MEDIA_UPLOAD_ENABLED=true+LANGFUSE_S3_MEDIA_UPLOAD_BUCKET=langfuse+LANGFUSE_S3_MEDIA_UPLOAD_ACCESS_KEY_ID=minio+LANGFUSE_S3_MEDIA_UPLOAD_SECRET_ACCESS_KEY=miniosecret+LANGFUSE_S3_MEDIA_UPLOAD_REGION=us-east-1+LANGFUSE_S3_MEDIA_UPLOAD_ENDPOINT=http://localhost:9090+## Necessary for minio compatibility+LANGFUSE_S3_MEDIA_UPLOAD_FORCE_PATH_STYLE=true+LANGFUSE_S3_MEDIA_UPLOAD_PREFIX=media/++# S3 Event Bucket Upload+## Set to true to test uploading all events to S3+LANGFUSE_S3_EVENT_UPLOAD_ENABLED=true+LANGFUSE_S3_EVENT_UPLOAD_BUCKET=langfuse+LANGFUSE_S3_EVENT_UPLOAD_ACCESS_KEY_ID=minio+LANGFUSE_S3_EVENT_UPLOAD_SECRET_ACCESS_KEY=miniosecret+LANGFUSE_S3_EVENT_UPLOAD_REGION=us-east-1+LANGFUSE_S3_EVENT_UPLOAD_ENDPOINT=http://localhost:9090+## Necessary for minio compatibility+LANGFUSE_S3_EVENT_UPLOAD_FORCE_PATH_STYLE=true+LANGFUSE_S3_EVENT_UPLOAD_PREFIX=events/++# Set during docker build of application+# Used to disable environment verification at build time+# DOCKER_BUILD=1++REDIS_HOST="127.0.0.1"+REDIS_PORT=6379+REDIS_AUTH="myredissecret"++# openssl rand -hex 32 used only here+ENCRYPTION_KEY=0000000000000000000000000000000000000000000000000000000000000000++# speeds up local development by not executing init scripts on server startup+NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT="false"\ No newline at end of filediff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex 290a4db506..1b5b3bc3b5 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -66,10 +66,78 @@ jobs:run: |timeout 10 bash -c 'until curl -f http://localhost:3000/api/public/health; do sleep 2; done'- tests-web:+ tests-web-sync:timeout-minutes: 20runs-on: ubuntu-latest- name: tests-web (node${{ matrix.node-version }}, pg${{ matrix.postgres-version }})+ name: tests-web-sync (node${{ matrix.node-version }}, pg${{ matrix.postgres-version }})+ strategy:+ matrix:+ node-version: [20]+ postgres-version: [12, 15]+ steps:+ - name: Set Swap Space+ uses: pierotofy/set-swap-space@master+ with:+ swap-size-gb: 10+ - uses: actions/checkout@v4+ - name: Install golang-migrate for Clickhouse migrations+ run: |+ curl -L https://github.com/golang-migrate/migrate/releases/download/v4.16.2/migrate.linux-amd64.tar.gz | tar xvz+ sudo mv migrate /usr/bin/migrate+ which migrate+ - uses: pnpm/action-setup@v3+ with:+ version: 9.5.0+ - name: Login to Docker Hub+ uses: docker/login-action@v3+ with:+ username: ${{ secrets.DOCKERHUB_USERNAME_READ }}+ password: ${{ secrets.DOCKERHUB_TOKEN_READ }}+ - name: Use Node.js ${{ matrix.node-version }}+ uses: actions/setup-node@v4+ with:+ node-version: ${{ matrix.node-version }}+ cache: "pnpm"+ cache-dependency-path: "pnpm-lock.yaml"+ - name: install dependencies+ run: |+ pnpm install+ - name: Load default env+ run: |+ cp .env.dev.example .env+ grep -v -e '^S3_BUCKET_NAME=' -e '^REDIS_HOST=' -e '^NEXT_PUBLIC_LANGFUSE_RUN_NEXT_INIT=' .env.dev.legacy.example > .env+ - name: Run + migrate+ run: |+ docker compose -f docker-compose.dev.yml up -d+ sleep 5 # Wait for PostgreSQL to accept connections+ docker compose ps+ env:+ POSTGRES_VERSION: ${{ matrix.postgres-version }}+ - name: Seed DB+ run: |+ pnpm run db:migrate+ pnpm --filter=shared ch:up+ - name: Build+ run: pnpm run build+ - name: Start Langfuse+ run: (pnpm run start&)+ env:+ LANGFUSE_INIT_ORG_ID: "seed-org-id"+ LANGFUSE_INIT_ORG_NAME: "Seed Org"+ LANGFUSE_INIT_PROJECT_ID: "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a"+ LANGFUSE_INIT_PROJECT_NAME: "Seed Project"+ LANGFUSE_INIT_PROJECT_PUBLIC_KEY: "pk-lf-1234567890"+ LANGFUSE_INIT_PROJECT_SECRET_KEY: "sk-lf-1234567890"+ LANGFUSE_INIT_USER_EMAIL: "[email protected]"+ LANGFUSE_INIT_USER_NAME: "Demo User"+ LANGFUSE_INIT_USER_PASSWORD: "password"+ - name: run test-sync+ run: pnpm --filter=web run test-sync++ tests-web-async:+ timeout-minutes: 20+ runs-on: ubuntu-latest+ name: tests-web-async (node${{ matrix.node-version }}, pg${{ matrix.postgres-version }})strategy:matrix:node-version: [20]@@ -286,11 +354,12 @@ jobs:needs:[lint,- tests-web,+ tests-web-sync,tests-worker,e2e-tests,test-docker-build,e2e-server-tests,+ tests-web-async,]if: always()steps:diff --git a/.gitignore b/.gitignoreindex 7cced275cc..844f5793ce 100644--- a/.gitignore+++ b/.gitignore@@ -39,6 +39,7 @@ yarn-error.log*!.env.dev.example!.env.local.example!.env.prod.example+!.env.dev.legacy.example# vercel.verceldiff --git a/web/jest.config.mjs b/web/jest.config.mjsindex fb6667812f..84b7fbca94 100644--- a/web/jest.config.mjs+++ b/web/jest.config.mjs@@ -13,8 +13,27 @@ const clientTestConfig = {};const serverTestConfig = {- displayName: "server",+ displayName: "sync-server",testMatch: ["/**/*.servertest.[jt]s?(x)"],+ testPathIgnorePatterns: ["async", "__e2e__"],+ testEnvironment: "jest-environment-node",+ setupFilesAfterEnv: ["<rootDir>/src/__tests__/after-teardown.ts"],+ globalTeardown: "<rootDir>/src/__tests__/teardown.ts",+};++const asyncServerTestConfig = {+ displayName: "async-server",+ testPathIgnorePatterns: ["__e2e__"],+ testMatch: ["/**/async/*.servertest.[jt]s?(x)"],+ testEnvironment: "jest-environment-node",+ setupFilesAfterEnv: ["<rootDir>/src/__tests__/after-teardown.ts"],+ globalTeardown: "<rootDir>/src/__tests__/teardown.ts",+};++const endToEndServerTestConfig = {+ displayName: "e2e-server",+ testMatch: ["/**/*.servertest.[jt]s?(x)"],+ testPathIgnorePatterns: ["__tests__"],testEnvironment: "jest-environment-node",setupFilesAfterEnv: ["<rootDir>/src/__tests__/after-teardown.ts"],globalTeardown: "<rootDir>/src/__tests__/teardown.ts",@@ -34,6 +53,18 @@ const config = {`/web/node_modules/(?!(${esModules.join("|")})/)`,],},+ {+ ...(await createJestConfig(asyncServerTestConfig)()),+ transformIgnorePatterns: [+ `/web/node_modules/(?!(${esModules.join("|")})/)`,+ ],+ },+ {+ ...(await createJestConfig(endToEndServerTestConfig)()),+ transformIgnorePatterns: [+ `/web/node_modules/(?!(${esModules.join("|")})/)`,+ ],+ },],};diff --git a/web/package.json b/web/package.jsonindex caa04d4853..79c59866d9 100644--- a/web/package.json+++ b/web/package.json@@ -14,10 +14,11 @@"prettier": "prettier --write ./src *.{ts,js}","clean": "rm -rf node_modules","start": "dotenv -e ../.env -- sh -c 'NEXT_MANUAL_SIG_HANDLE=true next start'",- "test": "dotenv -e ../.env -- jest --silent false --verbose false --runInBand --detectOpenHandles --testPathIgnorePatterns='__e2e__'",+ "test": "dotenv -e ../.env -- jest --silent false --verbose false --runInBand --detectOpenHandles --selectProjects async-server",+ "test-sync": "dotenv -e ../.env -- jest --silent false --verbose false --runInBand --detectOpenHandles --selectProjects sync-server","test:watch": "dotenv -e ../.env -- jest --watch --runInBand","test:e2e": "dotenv -e ../.env -- playwright test",- "test:e2e:server": "dotenv -e ../.env -- jest --runInBand --detectOpenHandles --verbose --testPathPattern='__e2e__'",+ "test:e2e:server": "dotenv -e ../.env -- jest --runInBand --detectOpenHandles --verbose --selectProjects e2e-server","models:migrate": "dotenv -e ../.env -- tsx scripts/model-match.ts"},"dependencies": {diff --git a/web/src/__tests__/async/some.servertest.ts b/web/src/__tests__/async/some.servertest.tsnew file mode 100644index 0000000000..dcae564420--- /dev/null+++ b/web/src/__tests__/async/some.servertest.ts@@ -0,0 +1,10 @@+describe("Sample Test Suite", () => {+ it("should return true for a simple truthy test", () => {+ expect(true).toBe(true);+ });++ it("should add two numbers correctly", () => {+ const sum = (a: number, b: number) => a + b;+ expect(sum(1, 2)).toBe(3);+ });+});