diff --git a/.agents/skills/self-hosted-release/SKILL.md b/.agents/skills/self-hosted-release/SKILL.md index 989b8f4c1a..b4d955c104 100644 --- a/.agents/skills/self-hosted-release/SKILL.md +++ b/.agents/skills/self-hosted-release/SKILL.md @@ -41,7 +41,7 @@ Build and run the target release with the local Docker Compose stack, then test docker compose down -v docker compose up -d --force-recreate --build --wait docker compose exec -T appwrite vars -curl -fsS http://localhost/v1/health/version +curl -fsS http://localhost:9520/v1/health/version ``` 2. Inspect runtime health before running tests: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c734df8e9..79978b9a8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -667,7 +667,7 @@ jobs: docker tag ${{ env.IMAGE }}:before ${{ env.IMAGE }} docker compose up -d --wait --no-build for attempt in $(seq 1 10); do - if curl -fsS http://localhost/v1/health/version; then + if curl -fsS http://localhost:9520/v1/health/version; then break fi if [ "$attempt" -eq 10 ]; then @@ -684,7 +684,7 @@ jobs: continue-on-error: true uses: grafana/run-k6-action@de51a7390bdf0ac85a3bef493691bd71d4c7c158 # v1.4.0 env: - APPWRITE_ENDPOINT: 'http://localhost/v1' + APPWRITE_ENDPOINT: 'http://localhost:9520/v1' APPWRITE_BENCHMARK_ITERATIONS: '5' APPWRITE_BENCHMARK_VUS: '1' APPWRITE_WORKER_TIMEOUT_MS: '120000' @@ -706,7 +706,7 @@ jobs: - name: Wait for benchmark ports if: always() run: | - for port in 80 443 8080 9503; do + for port in 9520 9521 9522 9503; do for attempt in $(seq 1 30); do if ! ss -ltn | awk '{print $4}' | grep -Eq "[:.]${port}$"; then break @@ -731,7 +731,7 @@ jobs: docker tag ${{ env.IMAGE }}:after ${{ env.IMAGE }} docker compose up -d --wait --no-build for attempt in $(seq 1 10); do - if curl -fsS http://localhost/v1/health/version; then + if curl -fsS http://localhost:9520/v1/health/version; then break fi if [ "$attempt" -eq 10 ]; then @@ -745,7 +745,7 @@ jobs: continue-on-error: true uses: grafana/run-k6-action@de51a7390bdf0ac85a3bef493691bd71d4c7c158 # v1.4.0 env: - APPWRITE_ENDPOINT: 'http://localhost/v1' + APPWRITE_ENDPOINT: 'http://localhost:9520/v1' APPWRITE_BENCHMARK_ITERATIONS: '5' APPWRITE_BENCHMARK_VUS: '1' APPWRITE_WORKER_TIMEOUT_MS: '120000' diff --git a/.gitpod.yml b/.gitpod.yml index 78375bb1f0..82130fa32d 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -17,7 +17,7 @@ tasks: --prefer-dist ports: - - port: 8080 + - port: 9520 visibility: public vscode: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d7ab96a4f..9dd25edc27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -281,11 +281,34 @@ Although the Appwrite API is a monolithic app, it has a very clear separation of Each container in Appwrite is a microservice on its own. Each service is an independent process that can scale without regard to any of the other services. -Currently, all the Appwrite microservices are intended to communicate using the TCP protocol over a private network. With the exception of the public-facing port 80 and 443, which by default are used to expose the Appwrite HTTP API, you should **avoid exposing any other services' ports**. +Currently, all the Appwrite microservices are intended to communicate using the TCP protocol over a private network. You should **avoid exposing services' ports** beyond what is needed for local development and debugging. ## Ports -Appwrite dev version uses ports 80 and 443 as an entry point to the Appwrite API and console. We also expose multiple ports in the range of 9500-9504 for debugging some of the Appwrite containers on dev mode. If you have any conflicts with the ports running on your system, you can easily replace them by editing Appwrite's docker-compose.yml file and executing `docker compose up -d` command. +Appwrite server dev publishes all host ports in the **9500–9522** range so the stack can run alongside other local services (including Appwrite Cloud on **9600–9699**). Access the API and console at `http://localhost:9520` (or `https://localhost:9521`). + +| Host port | Service | +|-----------|---------| +| 9520 | Traefik HTTP (API, console, dev hostnames) | +| 9521 | Traefik HTTPS | +| 9522 | Traefik HTTP (alt) | +| 9500 | Traefik dashboard | +| 9501 | Appwrite API only (direct; no console) | +| 9502 | Realtime only (direct; no console) | +| 9503 | Mail catcher | +| 9504 | Request catcher (webhook) | +| 9505 | Embedding | +| 9506 | Adminer | +| 9507 | Request catcher (SMS) | +| 9508 | Mongo Express | +| 9509 | GraphQL explorer | +| 9510 | MariaDB | +| 9511 | MongoDB | +| 9512 | PostgreSQL | +| 9513 | Redis | +| 9514 | Redis Insight | + +Containers still talk to each other on the internal Docker network using standard service ports (for example, `mariadb:3306`). The table above is only for connections from your host machine. If you still have a conflict, change the host side in `docker-compose.yml` or `docker-compose.override.yml` and run `docker compose up -d`. ## Technology Stack diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 05e31ece94..91625df148 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -10,7 +10,7 @@ services: networks: - appwrite ports: - - "8082:8081" + - "9508:8081" environment: ME_CONFIG_MONGODB_URL: "mongodb://root:${_APP_DB_ROOT_PASS}@appwrite-mongodb:27017/?replicaSet=rs0&directConnection=true" ME_CONFIG_BASICAUTH_USERNAME: ${_APP_DB_USER} @@ -76,7 +76,7 @@ services: - "traefik.http.routers.appwrite_redisinsight_https.service=appwrite_redisinsight" - "traefik.http.routers.appwrite_redisinsight_https.tls=true" ports: - - "8081:5540" + - "9514:5540" graphql-explorer: container_name: appwrite-graphql-explorer @@ -87,7 +87,7 @@ services: ports: - "9509:3000" environment: - - SERVER_URL=http://localhost/v1/graphql + - SERVER_URL=http://localhost:9520/v1/graphql configs: redisinsight-connections.json: diff --git a/docker-compose.yml b/docker-compose.yml index edeb936faa..dc328f0dc8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,15 @@ # This is a development version of THE Appwrite docker-compose.yml file. # Avoid using this file in your production environment. # We're exposing here sensitive ports and mounting code volumes for rapid development and debugging of the server stack. +# +# Development port map (host:container) +# ----------------------------------- +# Entry points: 9520:80 (HTTP), 9521:443 (HTTPS), 9522:80 (HTTP alt) +# Reserve 9600-9699 for Appwrite Cloud dev when running both stacks locally. +# 9500 Traefik dashboard, 9501 Appwrite API, 9502 Realtime, 9503 Mail catcher +# 9504 Request catcher (webhook), 9505 Embedding, 9507 Request catcher (SMS) +# 9510 MariaDB, 9511 MongoDB, 9512 PostgreSQL, 9513 Redis +# Dev tools in docker-compose.override.yml: 9506 Adminer, 9508 Mongo Express, 9509 GraphQL, 9514 Redis Insight x-logging: &x-logging logging: @@ -36,9 +45,9 @@ services: - --entrypoints.appwrite_websecure.address=:443 - --accesslog=true ports: - - 80:80 - - 8080:80 - - 443:443 + - 9520:80 + - 9522:80 + - 9521:443 - 9500:8080 volumes: - /var/run/docker.sock:/var/run/docker.sock @@ -281,7 +290,7 @@ services: image: appwrite-dev restart: unless-stopped ports: - - 9505:80 + - 9502:80 labels: - "traefik.enable=true" - "traefik.constraint-label-stack=appwrite" @@ -1314,7 +1323,7 @@ services: volumes: - appwrite-mariadb:/var/lib/mysql:rw ports: - - "3306:3306" + - "9510:3306" environment: - MYSQL_ROOT_PASSWORD=${_APP_DB_ROOT_PASS} - MYSQL_DATABASE=${_APP_DB_SCHEMA} @@ -1341,7 +1350,7 @@ services: - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro - ./mongo-entrypoint.sh:/mongo-entrypoint.sh:ro ports: - - "27017:27017" + - "9511:27017" environment: - MONGO_INITDB_ROOT_USERNAME=root - MONGO_INITDB_ROOT_PASSWORD=${_APP_DB_ROOT_PASS} @@ -1381,7 +1390,7 @@ services: volumes: - appwrite-postgresql:/var/lib/postgresql/18/data:rw ports: - - "5432:5432" + - "9512:5432" environment: - POSTGRES_DB=${_APP_DB_SCHEMA} - POSTGRES_USER=${_APP_DB_USER} @@ -1404,7 +1413,7 @@ services: EMBEDDING_MODELS: ${_APP_EMBEDDING_MODELS:-nomic-embed-text} container_name: appwrite-embedding ports: - - "3000:3000" + - "9505:3000" restart: unless-stopped # persistent for caching models across restarts and preloading volumes: @@ -1422,7 +1431,7 @@ services: --maxmemory-policy allkeys-lru --maxmemory-samples 5 ports: - - "6379:6379" + - "9513:6379" networks: - appwrite volumes: diff --git a/docs/sdks/cli/GETTING_STARTED.md b/docs/sdks/cli/GETTING_STARTED.md index 1cadb1bbda..8b907d298a 100644 --- a/docs/sdks/cli/GETTING_STARTED.md +++ b/docs/sdks/cli/GETTING_STARTED.md @@ -9,7 +9,7 @@ $ appwrite login ? Enter your password ******** ✓ Success ``` -This will also prompt you to enter your Appwrite endpoint ( default: http://localhost/v1 ) +This will also prompt you to enter your Appwrite endpoint ( default: http://localhost:9520/v1 ) * ### Initialising your project Once logged in, the CLI needs to be initialised before you can use it with your Appwrite project. You can do this with the `appwrite init project` command. @@ -139,5 +139,5 @@ $ appwrite client --reset The Appwrite CLI can also work in a CI environment. The initialisation of the CLI works a bit differently in CI. In CI, you set your `endpoint`, `projectId` and `API Key` using ```sh -appwrite client --endpoint http://localhost/v1 --projectId --key +appwrite client --endpoint http://localhost:9520/v1 --projectId --key ``` diff --git a/docs/sdks/flutter-dev/EXAMPLES.md b/docs/sdks/flutter-dev/EXAMPLES.md index d0cb0c2b2a..36537cbf18 100644 --- a/docs/sdks/flutter-dev/EXAMPLES.md +++ b/docs/sdks/flutter-dev/EXAMPLES.md @@ -6,7 +6,7 @@ Init your Appwrite client: Client client = Client(); client - .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setEndpoint('https://localhost:9521/v1') // Your Appwrite Endpoint .setProject('5e8cf4f46b5e8') // Your project ID .setSelfSigned() // Remove in production ; diff --git a/docs/sdks/flutter/EXAMPLES.md b/docs/sdks/flutter/EXAMPLES.md index d0cb0c2b2a..36537cbf18 100644 --- a/docs/sdks/flutter/EXAMPLES.md +++ b/docs/sdks/flutter/EXAMPLES.md @@ -6,7 +6,7 @@ Init your Appwrite client: Client client = Client(); client - .setEndpoint('https://localhost/v1') // Your Appwrite Endpoint + .setEndpoint('https://localhost:9521/v1') // Your Appwrite Endpoint .setProject('5e8cf4f46b5e8') // Your project ID .setSelfSigned() // Remove in production ; diff --git a/docs/sdks/react-native/GETTING_STARTED.md b/docs/sdks/react-native/GETTING_STARTED.md index a5c6f57c46..08b5c2f266 100644 --- a/docs/sdks/react-native/GETTING_STARTED.md +++ b/docs/sdks/react-native/GETTING_STARTED.md @@ -34,7 +34,7 @@ import { Client } from 'react-native-appwrite'; const client = new Client(); client - .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint + .setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') // Your project ID .setPlatform('com.example.myappwriteapp') // Your application ID or bundle ID. ; @@ -65,7 +65,7 @@ import { Client, Account } from 'react-native-appwrite'; const client = new Client(); client - .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint + .setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') .setPlatform('com.example.myappwriteapp') // YOUR application ID ; diff --git a/docs/sdks/web/GETTING_STARTED.md b/docs/sdks/web/GETTING_STARTED.md index cc75a3d3e5..db02a8428d 100644 --- a/docs/sdks/web/GETTING_STARTED.md +++ b/docs/sdks/web/GETTING_STARTED.md @@ -15,7 +15,7 @@ Initialize your SDK with your Appwrite server API endpoint and project ID which const client = new Client(); client - .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint + .setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') // Your project ID ; ``` @@ -44,7 +44,7 @@ account.create(ID.unique(), "email@example.com", "password", "Walter O'Brien") const client = new Client(); client - .setEndpoint('http://localhost/v1') // Your Appwrite Endpoint + .setEndpoint('http://localhost:9520/v1') // Your Appwrite Endpoint .setProject('455x34dfkj') ; diff --git a/docs/tutorials/add-translations.md b/docs/tutorials/add-translations.md index 68023fcf8b..ef56336799 100644 --- a/docs/tutorials/add-translations.md +++ b/docs/tutorials/add-translations.md @@ -149,13 +149,13 @@ First of all, we need to start a local instance of Appwrite. Thanks to Docker, t docker compose up -d ``` -If this is your first time running Appwrite, it may take up to a few minutes to download all images and start all containers. Once everything is started, you should see Appwrite running on `http://localhost:80`. When you visit this URL, it will ask you to sign up. After that, it will show you your empty dashboard where you need to create a new project - give it any name you want. Then you need to go to `Settings` of the project and copy `Project-ID`. +If this is your first time running Appwrite, it may take up to a few minutes to download all images and start all containers. Once everything is started, you should see Appwrite running on `http://localhost:9520`. When you visit this URL, it will ask you to sign up. After that, it will show you your empty dashboard where you need to create a new project - give it any name you want. Then you need to go to `Settings` of the project and copy `Project-ID`. If you are lost in the Appwrite dashboard, check out our [Article about Appwrite's dashboard](https://dev.to/appwrite/30daysofappwrite-appwrite-dashboard-15cc). Now, let's send the request. We will be editing headers of the request, so you will need a tool to do that, such as Postman or Insomnia. -First, let's see English translations. Let's set request type to `GET`, URL to `https://localhost/v1/locale/countries/eu` and add `X-Appwrite-Project` header. +First, let's see English translations. Let's set request type to `GET`, URL to `https://localhost:9521/v1/locale/countries/eu` and add `X-Appwrite-Project` header. ![English test](images/test-en.png) diff --git a/tests/benchmarks/bulk-operations/LargeDocumentCreation.js b/tests/benchmarks/bulk-operations/LargeDocumentCreation.js index c903ed2dba..138c68c4d1 100644 --- a/tests/benchmarks/bulk-operations/LargeDocumentCreation.js +++ b/tests/benchmarks/bulk-operations/LargeDocumentCreation.js @@ -1,6 +1,6 @@ import { check, sleep } from "k6"; import http from "k6/http"; -import { provisionProject, provisionDatabase, cleanup, unique } from "./utils.js"; +import { provisionProject, provisionDatabase, cleanup, unique, ENDPOINT } from "./utils.js"; const millionRecords = 1_000_000; const batchSize = 10_000; @@ -8,7 +8,7 @@ const numBatches = millionRecords / batchSize; export function setup() { const resources = provisionProject({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, email: 'test@test.com', password: 'password123', name: 'Test User', @@ -16,7 +16,7 @@ export function setup() { }); const { databaseId, collectionId } = provisionDatabase({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, apiHeaders: resources.apiHeaders }); @@ -31,7 +31,7 @@ export function setup() { attributes: ["name", "email"] }; - const indexRes = http.post(`http://localhost/v1/databases/${databaseId}/collections/${collectionId}/indexes`, + const indexRes = http.post(`${ENDPOINT}/databases/${databaseId}/collections/${collectionId}/indexes`, JSON.stringify(index), { headers: resources.apiHeaders }); @@ -57,7 +57,7 @@ export function setup() { })); requests.push({ method: "POST", - url: `http://localhost/v1/databases/${databaseId}/collections/${collectionId}/documents`, + url: `${ENDPOINT}/databases/${databaseId}/collections/${collectionId}/documents`, body: JSON.stringify({ documents: docs }), params: { headers: resources.apiHeaders, @@ -96,7 +96,7 @@ export default function (data) { const payload = JSON.stringify({ documents: docs }); const res = http.post( - `http://localhost/v1/databases/${data.databaseId}/collections/${data.collectionId}/documents`, + `${ENDPOINT}/databases/${data.databaseId}/collections/${data.collectionId}/documents`, payload, { headers: data.apiHeaders, diff --git a/tests/benchmarks/bulk-operations/documentCreation.js b/tests/benchmarks/bulk-operations/documentCreation.js index 730b6bb541..94ba690c0f 100644 --- a/tests/benchmarks/bulk-operations/documentCreation.js +++ b/tests/benchmarks/bulk-operations/documentCreation.js @@ -1,12 +1,12 @@ import { check, sleep } from "k6"; import http from "k6/http"; -import { provisionProject, provisionDatabase, cleanup, unique } from "./utils.js"; +import { provisionProject, provisionDatabase, cleanup, unique, ENDPOINT } from "./utils.js"; const amount = 10_000; export function setup() { const resources = provisionProject({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, email: 'test@test.com', password: 'password123', name: 'Test User', @@ -14,7 +14,7 @@ export function setup() { }); const { databaseId, collectionId } = provisionDatabase({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, apiHeaders: resources.apiHeaders }); @@ -54,7 +54,7 @@ export default function (data) { }); const res = http.post( - `http://localhost/v1/databases/${data.databaseId}/collections/${data.collectionId}/documents`, + `${ENDPOINT}/databases/${data.databaseId}/collections/${data.collectionId}/documents`, payload, { headers: data.apiHeaders diff --git a/tests/benchmarks/bulk-operations/noisyNeighbor.js b/tests/benchmarks/bulk-operations/noisyNeighbor.js index 4bfec4e564..3cb4c62510 100644 --- a/tests/benchmarks/bulk-operations/noisyNeighbor.js +++ b/tests/benchmarks/bulk-operations/noisyNeighbor.js @@ -1,7 +1,7 @@ import { check, sleep } from "k6"; import http from "k6/http"; import { Trend } from "k6/metrics"; -import { provisionProject, provisionDatabase, cleanup, unique } from "./utils.js"; +import { provisionProject, provisionDatabase, cleanup, unique, ENDPOINT } from "./utils.js"; // Custom Trend metric for light response time tracking export const lightResponseTime = new Trend("light_response_time", true); @@ -12,7 +12,7 @@ const LIGHT_AMOUNT = 10; // Light operation amount export function setup() { // Set up two separate projects - one for bulk operations (noisy neighbor) and one for light operations const heavyResources = provisionProject({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, email: 'heavy@test.com', password: 'password123', name: 'Heavy User', @@ -20,7 +20,7 @@ export function setup() { }); const lightResources = provisionProject({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, email: 'light@test.com', password: 'password123', name: 'Light User', @@ -29,12 +29,12 @@ export function setup() { // Set up databases for both projects const heavy = provisionDatabase({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, apiHeaders: heavyResources.apiHeaders }); const light = provisionDatabase({ - endpoint: 'http://localhost/v1', + endpoint: ENDPOINT, apiHeaders: lightResources.apiHeaders }); @@ -84,7 +84,7 @@ export function heavy(data) { const payload = JSON.stringify({ documents }); const res = http.post( - `http://localhost/v1/databases/${data.heavy.databaseId}/collections/${data.heavy.collectionId}/documents`, + `${ENDPOINT}/databases/${data.heavy.databaseId}/collections/${data.heavy.collectionId}/documents`, payload, { headers: data.heavy.apiHeaders @@ -103,7 +103,7 @@ export function light(data) { const startTime = new Date(); const res = http.post( - `http://localhost/v1/databases/${data.light.databaseId}/collections/${data.light.collectionId}/documents`, + `${ENDPOINT}/databases/${data.light.databaseId}/collections/${data.light.collectionId}/documents`, payload, { headers: data.light.apiHeaders diff --git a/tests/benchmarks/bulk-operations/utils.js b/tests/benchmarks/bulk-operations/utils.js index 5b8bbc6c67..56771e7acc 100644 --- a/tests/benchmarks/bulk-operations/utils.js +++ b/tests/benchmarks/bulk-operations/utils.js @@ -1,5 +1,8 @@ import http from 'k6/http'; import { check } from 'k6'; +import { ENDPOINT } from '../config.js'; + +export { ENDPOINT }; /** * @typedef {Object} AuthHeaders @@ -47,7 +50,7 @@ function assert(response, checkName, condition) { * - API Key creation * * @param {Object} config Configuration object - * @param {string} config.endpoint Base endpoint URL (e.g., 'http://localhost:80/v1') + * @param {string} config.endpoint Base endpoint URL (e.g., 'http://localhost:9520/v1') * @param {string} config.email Email for account creation * @param {string} config.password Password for account creation * @param {string} config.name Name for account creation @@ -165,7 +168,7 @@ export function provisionProject(config) { * Example usage: * * const config = { - * endpoint: 'http://localhost:80/v1', + * endpoint: 'http://localhost:9520/v1', * email: 'test@example.com', * password: 'complex-password', * name: 'Test User', diff --git a/tests/benchmarks/config.js b/tests/benchmarks/config.js new file mode 100644 index 0000000000..cb7b22677a --- /dev/null +++ b/tests/benchmarks/config.js @@ -0,0 +1,2 @@ +export const ENDPOINT = (__ENV.APPWRITE_ENDPOINT || 'http://localhost:9520/v1').replace(/\/+$/, ''); +export const REALTIME_URL = (__ENV.APPWRITE_REALTIME_URL || `${ENDPOINT.replace(/^http/, 'ws')}/realtime`).replace(/\/+$/, ''); diff --git a/tests/benchmarks/graphql/account/graphql-full-selection.js b/tests/benchmarks/graphql/account/graphql-full-selection.js index 84d41328d6..85521547c1 100644 --- a/tests/benchmarks/graphql/account/graphql-full-selection.js +++ b/tests/benchmarks/graphql/account/graphql-full-selection.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.post('http://localhost/v1/graphql', JSON.stringify({ + http.post(`${ENDPOINT}/graphql`, JSON.stringify({ query: `query { accountGet { _id diff --git a/tests/benchmarks/graphql/account/graphql-selection-set.js b/tests/benchmarks/graphql/account/graphql-selection-set.js index fd605121e9..befc161fbc 100644 --- a/tests/benchmarks/graphql/account/graphql-selection-set.js +++ b/tests/benchmarks/graphql/account/graphql-selection-set.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.post('http://localhost/v1/graphql', JSON.stringify({ + http.post(`${ENDPOINT}/graphql`, JSON.stringify({ query: `query { accountGet { _id email } }` }), { headers: { diff --git a/tests/benchmarks/graphql/account/rest.js b/tests/benchmarks/graphql/account/rest.js index 04037c28f1..2f60892b09 100644 --- a/tests/benchmarks/graphql/account/rest.js +++ b/tests/benchmarks/graphql/account/rest.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.get('http://localhost/v1/account', { + http.get(`${ENDPOINT}/account`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', diff --git a/tests/benchmarks/graphql/locale/graphql-batched.js b/tests/benchmarks/graphql/locale/graphql-batched.js index b2c633d49a..0dfd933f6d 100644 --- a/tests/benchmarks/graphql/locale/graphql-batched.js +++ b/tests/benchmarks/graphql/locale/graphql-batched.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.post('http://localhost/v1/graphql', JSON.stringify([{ + http.post(`${ENDPOINT}/graphql`, JSON.stringify([{ query: 'query { localeGetCountries { total countries { code } } }', }, { query: 'query { localeGetContinents { total continents { code } } }', diff --git a/tests/benchmarks/graphql/locale/graphql-full-selection.js b/tests/benchmarks/graphql/locale/graphql-full-selection.js index d66d6c44a7..219a78d0e9 100644 --- a/tests/benchmarks/graphql/locale/graphql-full-selection.js +++ b/tests/benchmarks/graphql/locale/graphql-full-selection.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.post('http://localhost/v1/graphql', JSON.stringify({ + http.post(`${ENDPOINT}/graphql`, JSON.stringify({ query: 'query { localeGetCountries { total countries { code name } } }', }), { headers: { diff --git a/tests/benchmarks/graphql/locale/graphql-selection-set.js b/tests/benchmarks/graphql/locale/graphql-selection-set.js index 46c6dcaa53..59f00e47e3 100644 --- a/tests/benchmarks/graphql/locale/graphql-selection-set.js +++ b/tests/benchmarks/graphql/locale/graphql-selection-set.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.post('http://localhost/v1/graphql', JSON.stringify({ + http.post(`${ENDPOINT}/graphql`, JSON.stringify({ query: 'query { localeGetCountries { total } }', }), { headers: { diff --git a/tests/benchmarks/graphql/locale/rest-serial.js b/tests/benchmarks/graphql/locale/rest-serial.js index 22f0c48ab0..acad4bcbc9 100644 --- a/tests/benchmarks/graphql/locale/rest-serial.js +++ b/tests/benchmarks/graphql/locale/rest-serial.js @@ -1,37 +1,38 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.get('http://localhost/v1/locale/countries', { + http.get(`${ENDPOINT}/locale/countries`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', } }) - http.get('http://localhost/v1/locale/continents', { + http.get(`${ENDPOINT}/locale/continents`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', } }) - http.get('http://localhost/v1/locale/countries/eu', { + http.get(`${ENDPOINT}/locale/countries/eu`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', } }) - http.get('http://localhost/v1/locale/countries/phones', { + http.get(`${ENDPOINT}/locale/countries/phones`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', } }) - http.get('http://localhost/v1/locale/languages', { + http.get(`${ENDPOINT}/locale/languages`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', } }) -} \ No newline at end of file +} diff --git a/tests/benchmarks/graphql/locale/rest.js b/tests/benchmarks/graphql/locale/rest.js index 0c9c57355f..d830fe58dc 100644 --- a/tests/benchmarks/graphql/locale/rest.js +++ b/tests/benchmarks/graphql/locale/rest.js @@ -1,10 +1,11 @@ import http from 'k6/http'; +import { ENDPOINT } from '../../config.js'; export const options = { vus: 20, duration: '60s', }; export default function () { - http.get('http://localhost/v1/locale/countries', { + http.get(`${ENDPOINT}/locale/countries`, { headers: { 'Content-Type': 'application/json', 'X-Appwrite-Project': 'test', diff --git a/tests/benchmarks/http-local.sh b/tests/benchmarks/http-local.sh index 734c825fda..15c4b64cbe 100755 --- a/tests/benchmarks/http-local.sh +++ b/tests/benchmarks/http-local.sh @@ -5,7 +5,7 @@ export K6_WEB_DASHBOARD="${K6_WEB_DASHBOARD:-true}" export K6_WEB_DASHBOARD_HOST="${K6_WEB_DASHBOARD_HOST:-127.0.0.1}" export K6_WEB_DASHBOARD_PORT="${K6_WEB_DASHBOARD_PORT:-5665}" export K6_WEB_DASHBOARD_EXPORT="${K6_WEB_DASHBOARD_EXPORT:-/tmp/appwrite-k6-report.html}" -export APPWRITE_ENDPOINT="${APPWRITE_ENDPOINT:-http://localhost/v1}" +export APPWRITE_ENDPOINT="${APPWRITE_ENDPOINT:-http://localhost:9520/v1}" export APPWRITE_WORKER_TIMEOUT_MS="${APPWRITE_WORKER_TIMEOUT_MS:-120000}" export APPWRITE_BENCHMARK_SUMMARY_PATH="${APPWRITE_BENCHMARK_SUMMARY_PATH:-/tmp/appwrite-k6-summary.json}" diff --git a/tests/benchmarks/http.js b/tests/benchmarks/http.js index ef42e99663..1e357f7dc9 100644 --- a/tests/benchmarks/http.js +++ b/tests/benchmarks/http.js @@ -1,3 +1,5 @@ +import { ENDPOINT } from './config.js'; + /* * Run locally: * Requires k6 and a running Appwrite instance. @@ -11,7 +13,6 @@ import { check, group, sleep } from 'k6'; import encoding from 'k6/encoding'; import { Counter, Trend } from 'k6/metrics'; -const ENDPOINT = (__ENV.APPWRITE_ENDPOINT || 'http://localhost/v1').replace(/\/+$/, ''); const CONSOLE_PROJECT = __ENV.APPWRITE_CONSOLE_PROJECT || 'console'; const REGION = __ENV.APPWRITE_REGION || 'default'; const REDIRECT_URL = __ENV.APPWRITE_BENCHMARK_REDIRECT_URL || 'http://localhost'; diff --git a/tests/benchmarks/ws.js b/tests/benchmarks/ws.js index 916458856f..0b657f6e4e 100644 --- a/tests/benchmarks/ws.js +++ b/tests/benchmarks/ws.js @@ -3,6 +3,7 @@ import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js'; import ws from 'k6/ws'; import { check } from 'k6'; +import { REALTIME_URL } from './config.js'; export let options = { stages: [ @@ -20,7 +21,7 @@ export let options = { export default function () { // const url = new URL('wss://appwrite-realtime.monitor-api.com/v1/realtime'); // url.searchParams.append('project', '604249e6b1a9f'); - const url = new URL('ws://localhost/v1/realtime'); + const url = new URL(REALTIME_URL); url.searchParams.append('project', 'console'); url.searchParams.append('channels[]', 'files');