diff --git a/.gitignore b/.gitignore index 551aa14..196ae54 100644 --- a/.gitignore +++ b/.gitignore @@ -130,4 +130,6 @@ dist .pnp.* db-backup/ -.venv \ No newline at end of file +.venv +deployments +/test/stressTest/output diff --git a/.vscode/launch.json b/.vscode/launch.json index 3f9be17..9559026 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,6 +20,20 @@ "name": "Debug frontend", "url": "http://localhost:5173", "webRoot": "${workspaceFolder}/client/" - } + }, + { + "name": "Docker: Attach to Node", + "type": "node", + "request": "attach", + "restart": true, + "port": 9229, + "address": "localhost", + "localRoot": "${workspaceFolder}", + "remoteRoot": "/app", + "protocol": "inspector", + "skipFiles": [ + "/**" + ] + } ] } \ No newline at end of file diff --git a/client/Dockerfile b/client/Dockerfile index f1021e6..32d487b 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -12,6 +12,10 @@ RUN npm install RUN npm run build -EXPOSE 5173 +ENV PORT=5173 +EXPOSE ${PORT} + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD curl -f http://localhost:${PORT} || exit 1 CMD [ "npm", "run", "preview" ] \ No newline at end of file diff --git a/create-branch-image.bat b/create-branch-image.bat new file mode 100644 index 0000000..02e6a21 --- /dev/null +++ b/create-branch-image.bat @@ -0,0 +1,74 @@ +@echo off +setlocal EnableDelayedExpansion + +:: Check if gh is installed +where gh >nul 2>&1 +if %errorlevel% neq 0 ( + echo GitHub CLI not found. Installing... + winget install --id GitHub.cli + if %errorlevel% neq 0 ( + echo Failed to install GitHub CLI. Exiting... + exit /b 1 + ) + echo GitHub CLI installed successfully. +) + +:: Check if user is authenticated +gh auth status >nul 2>&1 +if %errorlevel% neq 0 ( + echo GitHub CLI not authenticated. Please authenticate... + gh auth login + if %errorlevel% neq 0 ( + echo Failed to authenticate. Exiting... + exit /b 1 + ) + echo Authentication successful. +) + +:: Get the current branch name +for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do set BRANCH_NAME=%%i + +:: Run the GitHub workflow with the current branch name +echo Running GitHub workflow with branch %BRANCH_NAME%... +gh workflow run 119194149 --ref %BRANCH_NAME% + +:: Wait and validate workflow launch +set /a attempts=0 +set /a max_attempts=12 +echo Waiting for workflow to start... + +:wait_for_workflow +timeout /t 15 >nul +set /a attempts+=1 + +:: Get recent workflow run matching our criteria with in_progress status +for /f "tokens=*" %%i in ('gh run list --branch %BRANCH_NAME% --status in_progress --limit 1 --json databaseId --jq ".[0].databaseId"') do set WORKFLOW_RUN_ID=%%i + +if "%WORKFLOW_RUN_ID%"=="" ( + if !attempts! lss !max_attempts! ( + echo Attempt !attempts! of !max_attempts!: No running workflow found yet... + goto wait_for_workflow + ) else ( + echo Timeout waiting for workflow to start running. + exit /b 1 + ) +) + +echo Found running workflow ID: %WORKFLOW_RUN_ID% + +:monitor_progress +cls +echo Workflow Progress: +echo ---------------- +gh run view %WORKFLOW_RUN_ID% --json jobs --jq ".jobs[] | \"Job: \" + .name + \" - Status: \" + .status + if .conclusion != null then \" (\" + .conclusion + \")\" else \"\" end" +echo. + +:: Check if workflow is still running +for /f "tokens=*" %%i in ('gh run view %WORKFLOW_RUN_ID% --json status --jq ".status"') do set CURRENT_STATUS=%%i +if "%CURRENT_STATUS%" == "completed" ( + echo Workflow completed. + exit /b 0 +) + +timeout /t 5 >nul +goto monitor_progress \ No newline at end of file diff --git a/docker-compose.local.yaml b/docker-compose.local.yaml index 4b8f7a0..3c02939 100644 --- a/docker-compose.local.yaml +++ b/docker-compose.local.yaml @@ -3,21 +3,29 @@ version: '3' services: frontend: + container_name: frontend build: context: ./client dockerfile: Dockerfile - container_name: frontend ports: - "5173:5173" networks: - quiz_network restart: always - + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:$${PORT} || exit 1"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 + backend: build: context: ./server dockerfile: Dockerfile container_name: backend + networks: + - quiz_network ports: - "3000:3000" volumes: @@ -30,12 +38,15 @@ services: SENDER_EMAIL: infoevaluetonsavoir@gmail.com EMAIL_PSW: 'vvml wmfr dkzb vjzb' JWT_SECRET: haQdgd2jp09qb897GeBZyJetC8ECSpbFJe - FRONTEND_URL: "http://localhost:5173" depends_on: - - mongo - networks: - - quiz_network - restart: always + mongo: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:$${PORT}/health || exit 1"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 quizroom: # Forces image to update build: @@ -44,11 +55,17 @@ services: container_name: quizroom ports: - "4500:4500" - depends_on: - - backend + volumes: + - /var/run/docker.sock:/var/run/docker.sock networks: - quiz_network restart: always + healthcheck: + test: ["CMD", "/usr/src/app/healthcheck.sh"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 nginx: build: @@ -58,11 +75,25 @@ services: ports: - "80:80" depends_on: - - backend - - frontend + frontend: + condition: service_healthy + backend: + condition: service_healthy networks: - quiz_network restart: always + #environment: + # - PORT=8000 + # - FRONTEND_HOST=frontend + # - FRONTEND_PORT=5173 + # - BACKEND_HOST=backend + # - BACKEND_PORT=3000 + healthcheck: + test: ["CMD-SHELL", "wget --spider http://0.0.0.0:$${PORT}/health || exit 1"] + interval: 5s + timeout: 10s + start_period: 5s + retries: 6 mongo: image: mongo @@ -75,6 +106,12 @@ services: networks: - quiz_network restart: always + healthcheck: + test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"] + interval: 10s + timeout: 5s + retries: 3 + start_period: 20s watchtower: image: containrrr/watchtower diff --git a/nginx/.env.example b/nginx/.env.example new file mode 100644 index 0000000..3898f5f --- /dev/null +++ b/nginx/.env.example @@ -0,0 +1,5 @@ +PORT=80 +FRONTEND_HOST=frontend +FRONTEND_PORT=5173 +BACKEND_HOST=backend +BACKEND_PORT=3000 \ No newline at end of file diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 9f1280d..16e263f 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -1,20 +1,17 @@ # Stage 1: Build stage FROM nginx:1.27-alpine AS builder - # Install required packages RUN apk add --no-cache nginx-mod-http-js nginx-mod-http-keyval # Stage 2: Final stage FROM alpine:3.19 -# Copy Nginx and NJS modules from builder -COPY --from=builder /usr/sbin/nginx /usr/sbin/ -COPY --from=builder /usr/lib/nginx/modules/ /usr/lib/nginx/modules/ -COPY --from=builder /etc/nginx/ /etc/nginx/ -COPY --from=builder /usr/lib/nginx/ /usr/lib/nginx/ - -# Install required runtime dependencies +# Install gettext for envsubst and other dependencies RUN apk add --no-cache \ + gettext \ + curl \ + nginx-mod-http-js \ + nginx-mod-http-keyval \ pcre2 \ ca-certificates \ pcre \ @@ -24,15 +21,30 @@ RUN apk add --no-cache \ libxml2 \ libedit \ geoip \ - libxslt \ - && mkdir -p /var/cache/nginx \ + libxslt + +# Create base nginx directory +RUN mkdir -p /etc/nginx + +# Copy Nginx and NJS modules from builder +COPY --from=builder /usr/sbin/nginx /usr/sbin/ +COPY --from=builder /usr/lib/nginx/modules/ /usr/lib/nginx/modules/ +RUN rm -rf /etc/nginx/* +COPY --from=builder /etc/nginx/ /etc/nginx/ +COPY --from=builder /usr/lib/nginx/ /usr/lib/nginx/ + +# Setup directories and permissions +RUN mkdir -p /var/cache/nginx \ && mkdir -p /var/log/nginx \ && mkdir -p /etc/nginx/conf.d \ && mkdir -p /etc/nginx/njs \ - && ln -sf /dev/stdout /var/log/nginx/access.log \ - && ln -sf /dev/stderr /var/log/nginx/error.log \ - && addgroup -S nginx \ - && adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx + && mkdir -p /etc/nginx/templates \ + && chown -R nginx:nginx /var/cache/nginx \ + && chown -R nginx:nginx /var/log/nginx \ + && chown -R nginx:nginx /etc/nginx \ + && touch /var/run/nginx.pid \ + && chown nginx:nginx /var/run/nginx.pid \ + && chmod 777 /var/log/nginx # Copy necessary libraries from builder COPY --from=builder /usr/lib/libxml2.so* /usr/lib/ @@ -45,25 +57,34 @@ RUN echo 'load_module modules/ngx_http_js_module.so;' > /tmp/nginx.conf && \ cat /etc/nginx/nginx.conf >> /tmp/nginx.conf && \ mv /tmp/nginx.conf /etc/nginx/nginx.conf -# Copy our configuration -COPY conf.d/default.conf /etc/nginx/conf.d/ +# Copy configurations +COPY templates/default.conf /etc/nginx/templates/ COPY njs/main.js /etc/nginx/njs/ +COPY entrypoint.sh /entrypoint.sh +RUN dos2unix /entrypoint.sh -# Set proper permissions -RUN chown -R nginx:nginx /var/cache/nginx \ - && chown -R nginx:nginx /var/log/nginx \ - && chown -R nginx:nginx /etc/nginx/conf.d \ - && touch /var/run/nginx.pid \ - && chown -R nginx:nginx /var/run/nginx.pid +ENV PORT=80 \ + FRONTEND_HOST=frontend \ + FRONTEND_PORT=5173 \ + BACKEND_HOST=backend \ + BACKEND_PORT=3000 -# Verify the configuration -# RUN nginx -t --dry-run +# Set final permissions +RUN chmod +x /entrypoint.sh && \ + chown -R nginx:nginx /etc/nginx && \ + chown -R nginx:nginx /var/log/nginx && \ + chown -R nginx:nginx /var/cache/nginx && \ + chmod 755 /etc/nginx && \ + chmod 777 /etc/nginx/conf.d && \ + chmod 644 /etc/nginx/templates/default.conf && \ + chmod 644 /etc/nginx/conf.d/default.conf -# Switch to non-root user +# Switch to nginx user USER nginx -# Expose HTTP port -EXPOSE 80 +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget -q --spider http://0.0.0.0:${PORT}/health || exit 1 -# Start Nginx -CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +# Start Nginx using entrypoint script +# CMD [ "/bin/sh","-c","sleep 3600" ] # For debugging +ENTRYPOINT [ "/entrypoint.sh" ] \ No newline at end of file diff --git a/nginx/entrypoint.sh b/nginx/entrypoint.sh new file mode 100644 index 0000000..7e4739c --- /dev/null +++ b/nginx/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# entrypoint.sh + +# We are already running as nginx user +envsubst '${PORT} ${FRONTEND_HOST} ${FRONTEND_PORT} ${BACKEND_HOST} ${BACKEND_PORT}' \ + < /etc/nginx/templates/default.conf \ + > /etc/nginx/conf.d/default.conf + +# Start nginx +exec nginx -g "daemon off;" \ No newline at end of file diff --git a/nginx/conf.d/default.conf b/nginx/templates/default.conf similarity index 71% rename from nginx/conf.d/default.conf rename to nginx/templates/default.conf index fd1bc38..7fdff8d 100644 --- a/nginx/conf.d/default.conf +++ b/nginx/templates/default.conf @@ -8,17 +8,37 @@ map $http_upgrade $connection_upgrade { } upstream frontend { - server frontend:5173; + server ${FRONTEND_HOST}:${FRONTEND_PORT}; } upstream backend { - server backend:3000; + server ${BACKEND_HOST}:${BACKEND_PORT}; } server { - listen 80; + listen ${PORT}; set $proxy_target ""; + + location /health { + access_log off; + add_header Content-Type text/plain; + return 200 'healthy'; + } + + location /backend-health { + proxy_pass http://backend/health; + proxy_http_version 1.1; + proxy_set_header Host $host; + access_log off; + } + + location /frontend-health { + proxy_pass http://frontend; + proxy_http_version 1.1; + proxy_set_header Host $host; + access_log off; + } location /api { proxy_pass http://backend; diff --git a/quizRoom/Dockerfile b/quizRoom/Dockerfile index d02f5f2..03bae93 100644 --- a/quizRoom/Dockerfile +++ b/quizRoom/Dockerfile @@ -1,9 +1,8 @@ -# Use the Node base image +# Use the Node base image FROM node:18 AS quizroom -ARG PORT=4500 -ENV PORT=${PORT} -ENV ROOM_ID=${ROOM_ID} +ENV PORT=4500 +ENV ROOM_ID=000000 # Create a working directory WORKDIR /usr/src/app @@ -15,6 +14,10 @@ RUN npm install # Copy the rest of the source code to the container COPY . . +# Ensure healthcheck.sh has execution permissions +COPY healthcheck.sh /usr/src/app/healthcheck.sh +RUN chmod +x /usr/src/app/healthcheck.sh + # Build the TypeScript code RUN npm run build @@ -26,4 +29,4 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=30s --retries=3 \ CMD /usr/src/app/healthcheck.sh # Start the server using the compiled JavaScript file -CMD ["node", "dist/app.js"] +CMD ["node", "dist/app.js"] \ No newline at end of file diff --git a/quizRoom/app.ts b/quizRoom/app.ts index 0e40adc..81347b4 100644 --- a/quizRoom/app.ts +++ b/quizRoom/app.ts @@ -2,7 +2,8 @@ import http from "http"; import { Server, ServerOptions } from "socket.io"; import { setupWebsocket } from "./socket/setupWebSocket"; import dotenv from "dotenv"; -import express from 'express'; +import express from "express"; +import os from "os"; // Import the os module // Load environment variables dotenv.config(); @@ -36,6 +37,7 @@ app.get('/health', (_, res) => { } }); + const ioOptions: Partial = { path: `/api/room/${roomId}/socket`, cors: { @@ -52,4 +54,4 @@ setupWebsocket(io); server.listen(port, () => { console.log(`WebSocket server is running on port ${port}`); -}); \ No newline at end of file +}); diff --git a/quizRoom/docker-compose.yml b/quizRoom/docker-compose.yml index bf98e56..aa43c9f 100644 --- a/quizRoom/docker-compose.yml +++ b/quizRoom/docker-compose.yml @@ -8,6 +8,8 @@ services: - PORT=${PORT:-4500} ports: - "${PORT:-4500}:${PORT:-4500}" + volumes: + - /var/run/docker.sock:/var/run/docker.sock environment: - PORT=${PORT:-4500} - ROOM_ID=${ROOM_ID} diff --git a/quizRoom/healthcheck.sh b/quizRoom/healthcheck.sh index a3ee74d..7b0e27f 100644 --- a/quizRoom/healthcheck.sh +++ b/quizRoom/healthcheck.sh @@ -1,2 +1,2 @@ -#!/bin/sh +#!/bin/bash curl -f "http://0.0.0.0:${PORT}/health" || exit 1 \ No newline at end of file diff --git a/quizRoom/package-lock.json b/quizRoom/package-lock.json index fd913e2..105118b 100644 --- a/quizRoom/package-lock.json +++ b/quizRoom/package-lock.json @@ -9,17 +9,24 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "dockerode": "^4.0.2", "dotenv": "^16.4.5", "express": "^4.21.1", "http": "^0.0.1-security", "socket.io": "^4.8.1" }, "devDependencies": { + "@types/dockerode": "^3.3.32", "@types/express": "^5.0.0", "ts-node": "^10.9.2", "typescript": "^5.6.3" } }, + "node_modules/@balena/dockerignore": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@balena/dockerignore/-/dockerignore-1.0.2.tgz", + "integrity": "sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==" + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -118,6 +125,27 @@ "@types/node": "*" } }, + "node_modules/@types/docker-modem": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/@types/docker-modem/-/docker-modem-3.0.6.tgz", + "integrity": "sha512-yKpAGEuKRSS8wwx0joknWxsmLha78wNMe9R2S3UNsVOkZded8UqOrV8KoeDXoXsjndxwyF3eIhyClGbO1SEhEg==", + "dev": true, + "dependencies": { + "@types/node": "*", + "@types/ssh2": "*" + } + }, + "node_modules/@types/dockerode": { + "version": "3.3.32", + "resolved": "https://registry.npmjs.org/@types/dockerode/-/dockerode-3.3.32.tgz", + "integrity": "sha512-xxcG0g5AWKtNyh7I7wswLdFvym4Mlqks5ZlKzxEUrGHS0r0PUOfxm2T0mspwu10mHQqu3Ck3MI3V2HqvLWE1fg==", + "dev": true, + "dependencies": { + "@types/docker-modem": "*", + "@types/node": "*", + "@types/ssh2": "*" + } + }, "node_modules/@types/express": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.0.tgz", @@ -195,6 +223,30 @@ "@types/send": "*" } }, + "node_modules/@types/ssh2": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/@types/ssh2/-/ssh2-1.15.1.tgz", + "integrity": "sha512-ZIbEqKAsi5gj35y4P4vkJYly642wIbY6PqoN0xiyQGshKUGXR9WQjF/iF9mXBQ8uBKy3ezfsCkcoHKhd0BzuDA==", + "dev": true, + "dependencies": { + "@types/node": "^18.11.18" + } + }, + "node_modules/@types/ssh2/node_modules/@types/node": { + "version": "18.19.67", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.67.tgz", + "integrity": "sha512-wI8uHusga+0ZugNp0Ol/3BqQfEcCCNfojtO6Oou9iVNGPTL6QNSdnUdqq85fRgIorLhLMuPIKpsN98QE9Nh+KQ==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/ssh2/node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -243,6 +295,33 @@ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", "license": "MIT" }, + "node_modules/asn1": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", + "dependencies": { + "safer-buffer": "~2.1.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/base64id": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", @@ -251,6 +330,24 @@ "node": "^4.5.0 || >= 5.9" } }, + "node_modules/bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", + "dependencies": { + "tweetnacl": "^0.14.3" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, "node_modules/body-parser": { "version": "1.20.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", @@ -290,6 +387,38 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "license": "MIT" }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buildcheck": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/buildcheck/-/buildcheck-0.0.6.tgz", + "integrity": "sha512-8f9ZJCUXyT1M35Jx7MkBgmBMo3oHTTBIPLiY9xyL0pl3T5RwcPEY8cUHr5LBNfu/fk6c2T4DJZuVM/8ZZT2D2A==", + "optional": true, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -318,6 +447,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -365,6 +499,20 @@ "node": ">= 0.10" } }, + "node_modules/cpu-features": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.10.tgz", + "integrity": "sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "buildcheck": "~0.0.6", + "nan": "^2.19.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -432,6 +580,33 @@ "node": ">=0.3.1" } }, + "node_modules/docker-modem": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/docker-modem/-/docker-modem-5.0.3.tgz", + "integrity": "sha512-89zhop5YVhcPEt5FpUFGr3cDyceGhq/F9J+ZndQ4KfqNvfbJpPMfgeixFgUj5OjCYAboElqODxY5Z1EBsSa6sg==", + "dependencies": { + "debug": "^4.1.1", + "readable-stream": "^3.5.0", + "split-ca": "^1.0.1", + "ssh2": "^1.15.0" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/dockerode": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/dockerode/-/dockerode-4.0.2.tgz", + "integrity": "sha512-9wM1BVpVMFr2Pw3eJNXrYYt6DT9k0xMcsSCjtPvyQ+xa1iPg/Mo3T/gUcwI0B2cczqCeCYRPF8yFYDwtFXT0+w==", + "dependencies": { + "@balena/dockerignore": "^1.0.2", + "docker-modem": "^5.0.3", + "tar-fs": "~2.0.1" + }, + "engines": { + "node": ">= 8.0" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -458,6 +633,14 @@ "node": ">= 0.8" } }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, "node_modules/engine.io": { "version": "6.6.2", "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz", @@ -639,6 +822,11 @@ "node": ">= 0.6" } }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -760,6 +948,25 @@ "node": ">=0.10.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -839,11 +1046,22 @@ "node": ">= 0.6" } }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" }, + "node_modules/nan": { + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", + "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==", + "optional": true + }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -884,6 +1102,14 @@ "node": ">= 0.8" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -912,6 +1138,15 @@ "node": ">= 0.10" } }, + "node_modules/pump": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", + "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, "node_modules/qs": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", @@ -951,6 +1186,19 @@ "node": ">= 0.8" } }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1119,6 +1367,28 @@ "node": ">=10.0.0" } }, + "node_modules/split-ca": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split-ca/-/split-ca-1.0.1.tgz", + "integrity": "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==" + }, + "node_modules/ssh2": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.16.0.tgz", + "integrity": "sha512-r1X4KsBGedJqo7h8F5c4Ybpcr5RjyP+aWIG007uBPRjmdQWfEiVLzSK71Zji1B9sKxwaCvD8y8cwSkYrlLiRRg==", + "hasInstallScript": true, + "dependencies": { + "asn1": "^0.2.6", + "bcrypt-pbkdf": "^1.0.2" + }, + "engines": { + "node": ">=10.16.0" + }, + "optionalDependencies": { + "cpu-features": "~0.0.10", + "nan": "^2.20.0" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -1128,6 +1398,40 @@ "node": ">= 0.8" } }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/tar-fs": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz", + "integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.0.0" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/toidentifier": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", @@ -1180,6 +1484,11 @@ } } }, + "node_modules/tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -1220,6 +1529,11 @@ "node": ">= 0.8" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -1243,6 +1557,11 @@ "node": ">= 0.8" } }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "node_modules/ws": { "version": "8.17.1", "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", diff --git a/quizRoom/package.json b/quizRoom/package.json index b4fb43e..fb9f258 100644 --- a/quizRoom/package.json +++ b/quizRoom/package.json @@ -12,11 +12,13 @@ "license": "ISC", "description": "", "devDependencies": { + "@types/dockerode": "^3.3.32", "@types/express": "^5.0.0", "ts-node": "^10.9.2", "typescript": "^5.6.3" }, "dependencies": { + "dockerode": "^4.0.2", "dotenv": "^16.4.5", "express": "^4.21.1", "http": "^0.0.1-security", diff --git a/quizRoom/socket/setupWebSocket.ts b/quizRoom/socket/setupWebSocket.ts index d5e2ab0..3ed5a24 100644 --- a/quizRoom/socket/setupWebSocket.ts +++ b/quizRoom/socket/setupWebSocket.ts @@ -1,4 +1,6 @@ import { Server, Socket } from "socket.io"; +import Docker from 'dockerode'; +import fs from 'fs'; const MAX_USERS_PER_ROOM = 60; const MAX_TOTAL_CONNECTIONS = 2000; @@ -19,10 +21,11 @@ export const setupWebsocket = (io: Server): void => { socket.on("create-room", (sentRoomName) => { // Ensure sentRoomName is a string before applying toUpperCase() - const roomName = (typeof sentRoomName === "string" && sentRoomName.trim() !== "") - ? sentRoomName.toUpperCase() + const roomName = (typeof sentRoomName === "string" && sentRoomName.trim() !== "") + ? sentRoomName.toUpperCase() : generateRoomName(); - + + console.log(`Created room with name: ${roomName}`); if (!io.sockets.adapter.rooms.get(roomName)) { socket.join(roomName); socket.emit("create-success", roomName); @@ -96,10 +99,138 @@ export const setupWebsocket = (io: Server): void => { socket.on("error", (error) => { console.error("WebSocket server error:", error); }); + + + // Stress Testing + + socket.on("message-from-teacher", ({ roomName, message }: { roomName: string; message: string }) => { + console.log(`Message reçu dans la salle ${roomName} : ${message}`); + socket.to(roomName).emit("message-sent-teacher", { message }); + }); + + socket.on("message-from-student", ({ roomName, message }: { roomName: string; message: string }) => { + console.log(`Message reçu dans la salle ${roomName} : ${message}`); + socket.to(roomName).emit("message-sent-student", { message }); + }); + + interface ContainerStats { + containerId: string; + containerName: string; + memoryUsedMB: number | null; + memoryUsedPercentage: number | null; + cpuUsedPercentage: number | null; + error?: string; + } + + class ContainerMetrics { + private docker: Docker; + private containerName: string; + + private bytesToMB(bytes: number): number { + return Math.round(bytes / (1024 * 1024)); + } + + constructor() { + this.docker = new Docker({ + socketPath: process.platform === 'win32' ? '//./pipe/docker_engine' : '/var/run/docker.sock' + }); + this.containerName = `room_${process.env.ROOM_ID}`; + } + + private async getContainerNetworks(containerId: string): Promise { + const container = this.docker.getContainer(containerId); + const info = await container.inspect(); + return Object.keys(info.NetworkSettings.Networks); + } + + public async getAllContainerStats(): Promise { + try { + // First get our container to find its networks + const ourContainer = await this.docker.listContainers({ + all: true, + filters: { name: [this.containerName] } + }); + + if (!ourContainer.length) { + throw new Error(`Container ${this.containerName} not found`); + } + + const ourNetworks = await this.getContainerNetworks(ourContainer[0].Id); + + // Get all containers + const allContainers = await this.docker.listContainers(); + + // Get stats for containers on the same networks + const containerStats = await Promise.all( + allContainers.map(async (container): Promise => { + try { + const containerNetworks = await this.getContainerNetworks(container.Id); + // Check if container shares any network with our container + if (!containerNetworks.some(network => ourNetworks.includes(network))) { + return null; + } + + const stats = await this.docker.getContainer(container.Id).stats({ stream: false }); + + const memoryStats = { + usage: stats.memory_stats.usage, + limit: stats.memory_stats.limit || 0, + percent: stats.memory_stats.limit ? (stats.memory_stats.usage / stats.memory_stats.limit) * 100 : 0 + }; + + const cpuDelta = stats.cpu_stats?.cpu_usage?.total_usage - (stats.precpu_stats?.cpu_usage?.total_usage || 0); + const systemDelta = stats.cpu_stats?.system_cpu_usage - (stats.precpu_stats?.system_cpu_usage || 0); + const cpuPercent = systemDelta > 0 ? (cpuDelta / systemDelta) * (stats.cpu_stats?.online_cpus || 1) * 100 : 0; + + return { + containerId: container.Id, + containerName: container.Names[0].replace(/^\//, ''), + memoryUsedMB: this.bytesToMB(memoryStats.usage), + memoryUsedPercentage: memoryStats.percent, + cpuUsedPercentage: cpuPercent + }; + } catch (error) { + return { + containerId: container.Id, + containerName: container.Names[0].replace(/^\//, ''), + memoryUsedMB: null, + memoryUsedPercentage: null, + cpuUsedPercentage: null, + error: error instanceof Error ? error.message : String(error) + }; + } + }) + ); + + // Change the filter to use proper type predicate + return containerStats.filter((stats): stats is ContainerStats => stats !== null); + } catch (error) { + console.error('Stats error:', error); + return [{ + containerId: 'unknown', + containerName: 'unknown', + memoryUsedMB: null, + memoryUsedPercentage: null, + cpuUsedPercentage: null, + error: error instanceof Error ? error.message : String(error) + }]; + } + } + } + + const containerMetrics = new ContainerMetrics(); + + socket.on("get-usage", async () => { + try { + const usageData = await containerMetrics.getAllContainerStats(); + socket.emit("usage-data", usageData); + } catch (error) { + socket.emit("error", { message: "Failed to retrieve usage data" }); + } + }); + }); - - const generateRoomName = (length = 6): string => { const characters = "0123456789"; let result = ""; diff --git a/server/Dockerfile b/server/Dockerfile index 02bb17e..8dbd6ff 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -8,6 +8,10 @@ RUN npm install COPY ./ . -EXPOSE 4400 +ENV PORT=3000 +EXPOSE ${PORT} + +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:${PORT}/health || exit 1 CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/server/app.js b/server/app.js index afba445..3b4e7db 100644 --- a/server/app.js +++ b/server/app.js @@ -47,6 +47,7 @@ const folderRouter = require('./routers/folders.js'); const quizRouter = require('./routers/quiz.js'); const imagesRouter = require('./routers/images.js'); const roomRouter = require('./routers/rooms.js'); +const healthRouter = require('./routers/health.js'); // Setup environment dotenv.config(); @@ -71,6 +72,7 @@ app.use('/api/folder', folderRouter); app.use('/api/quiz', quizRouter); app.use('/api/image', imagesRouter); app.use('/api/room', roomRouter); +app.use('/health', healthRouter); app.use(errorHandler); diff --git a/server/roomsProviders/docker-provider.js b/server/roomsProviders/docker-provider.js index fb7fc53..1da5c3b 100644 --- a/server/roomsProviders/docker-provider.js +++ b/server/roomsProviders/docker-provider.js @@ -8,7 +8,7 @@ class DockerRoomProvider extends BaseRoomProvider { const dockerSocket = process.env.DOCKER_SOCKET || "/var/run/docker.sock"; this.docker = new Docker({ socketPath: dockerSocket }); - this.docker_network = 'evaluetonsavoir_quiz_network'; + this.docker_network = process.env.QUIZ_NETWORK_NAME || 'evaluetonsavoir_quiz_network'; } async syncInstantiatedRooms() { @@ -46,10 +46,52 @@ class DockerRoomProvider extends BaseRoomProvider { } } + async checkAndPullImage(imageName) { + try { + const images = await this.docker.listImages({ all: true }); + //console.log('Images disponibles:', images.map(img => ({ + // RepoTags: img.RepoTags || [], + // Id: img.Id + //}))); + + const imageExists = images.some(img => { + const tags = img.RepoTags || []; + return tags.includes(imageName) || + tags.includes(`${imageName}:latest`) || + img.Id.includes(imageName); + }); + + if (!imageExists) { + console.log(`L'image ${imageName} n'a pas été trouvée localement, tentative de téléchargement...`); + try { + await this.docker.pull(imageName); + console.log(`L'image ${imageName} a été téléchargée avec succès`); + } catch (pullError) { + const localImages = await this.docker.listImages({ all: true }); + const foundLocally = localImages.some(img => + (img.RepoTags || []).includes(imageName) || + (img.RepoTags || []).includes(`${imageName}:latest`) + ); + + if (!foundLocally) { + throw new Error(`Impossible de trouver ou de télécharger l'image ${imageName}: ${pullError.message}`); + } else { + console.log(`L'image ${imageName} a été trouvée localement après vérification supplémentaire`); + } + } + } else { + console.log(`L'image ${imageName} a été trouvée localement`); + } + } catch (error) { + throw new Error(`Une erreur est survenue lors de la vérification/téléchargement de l'image ${imageName}: ${error.message}`); + } + } + async createRoom(roomId, options) { const container_name = `room_${roomId}`; try { + await this.checkAndPullImage(this.quiz_docker_image); const containerConfig = { Image: this.quiz_docker_image, name: container_name, @@ -57,7 +99,10 @@ class DockerRoomProvider extends BaseRoomProvider { NetworkMode: this.docker_network, RestartPolicy: { Name: 'unless-stopped' - } + }, + Binds: [ + '/var/run/docker.sock:/var/run/docker.sock' + ] }, Env: [ `ROOM_ID=${roomId}`, diff --git a/server/routers/health.js b/server/routers/health.js new file mode 100644 index 0000000..008452e --- /dev/null +++ b/server/routers/health.js @@ -0,0 +1,20 @@ +const express = require('express'); +const router = express.Router(); + +router.get('/', async (req, res) => { + try { + const dbStatus = await require('../config/db.js').getConnection() ? 'connected' : 'disconnected'; + res.json({ + status: 'healthy', + timestamp: new Date(), + db: dbStatus + }); + } catch (error) { + res.status(500).json({ + status: 'unhealthy', + error: error.message + }); + } +}); + +module.exports = router; \ No newline at end of file diff --git a/test/stressTest/.dockerignore b/test/stressTest/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/test/stressTest/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/test/stressTest/.env.example b/test/stressTest/.env.example new file mode 100644 index 0000000..254f2d4 --- /dev/null +++ b/test/stressTest/.env.example @@ -0,0 +1,19 @@ +# Target url +BASE_URL=http://msevignyl.duckdns.org + +# Connection account +USER_EMAIL=admin@admin.com +USER_PASSWORD=admin + +# Stress test parameters +NUMBER_ROOMS=5 +USERS_PER_ROOM=60 + +# Optionnal + + +MAX_MESSAGES_ROUND=20 +CONVERSATION_INTERVAL=1000 +MESSAGE_RESPONSE_TIMEOUT=5000 +BATCH_DELAY=1000 +BATCH_SIZE=10 \ No newline at end of file diff --git a/test/stressTest/Dockerfile b/test/stressTest/Dockerfile new file mode 100644 index 0000000..a92942b --- /dev/null +++ b/test/stressTest/Dockerfile @@ -0,0 +1,13 @@ +FROM node:18 + +WORKDIR /app + +COPY package*.json ./ + +RUN npm install + +COPY . . + +VOLUME /app/output + +CMD ["node", "main.js"] \ No newline at end of file diff --git a/test/stressTest/README.md b/test/stressTest/README.md new file mode 100644 index 0000000..fbed7e1 --- /dev/null +++ b/test/stressTest/README.md @@ -0,0 +1,51 @@ +# Test de Charge - EvalueTonSavoir + +Ce conteneur permet d'exécuter des tests de charge sur l'application EvalueTonSavoir. + +## Prérequis + +- Docker +- Docker Compose + +## Configuration + +1. Créez un fichier `.env` à partir du modèle `.env.example`: + +```bash +copy .env.example .env +``` + +2. Modifiez les variables dans le fichier .env: + +```bash +# URL de l'application cible +BASE_URL=http://votre-url.com + +# Compte de connexion +USER_EMAIL=admin@admin.com +USER_PASSWORD=admin + +# Paramètres du test de charge +NUMBER_ROOMS=5 # Nombre de salles à créer +USERS_PER_ROOM=60 # Nombre d'utilisateurs par salle + +``` +#### Paramètres optionnels +Dans le fichier .env, vous pouvez aussi configurer: + +```bash +MAX_MESSAGES_ROUND=20 # Messages maximum par cycle +CONVERSATION_INTERVAL=1000 # Intervalle entre les messages (ms) +MESSAGE_RESPONSE_TIMEOUT=5000 # Timeout des réponses (ms) +BATCH_DELAY=1000 # Délai entre les lots (ms) +BATCH_SIZE=10 # Taille des lots d'utilisateurs +``` + +## Démarrage +Pour lancer le test de charge: + +Les résultats seront disponibles dans le dossier output/. + +```bash +docker compose up +``` diff --git a/test/stressTest/class/metrics.js b/test/stressTest/class/metrics.js new file mode 100644 index 0000000..a28bff0 --- /dev/null +++ b/test/stressTest/class/metrics.js @@ -0,0 +1,46 @@ +export class TestMetrics { + constructor() { + this.reset(); + } + + reset() { + this.roomsCreated = 0; + this.roomsFailed = 0; + this.usersConnected = 0; + this.userConnectionsFailed = 0; + this.messagesAttempted = 0; + this.messagesSent = 0; + this.messagesReceived = 0; + this.errors = new Map(); + } + + logError(category, error) { + if (!this.errors.has(category)) { + this.errors.set(category, []); + } + this.errors.get(category).push(error); + } + + getSummary() { + return { + rooms: { + created: this.roomsCreated, + failed: this.roomsFailed, + total: this.roomsCreated + this.roomsFailed + }, + users: { + connected: this.usersConnected, + failed: this.userConnectionsFailed, + total: this.usersConnected + this.userConnectionsFailed + }, + messages: { + attempted: this.messagesAttempted, + sent: this.messagesSent, + received: this.messagesReceived + }, + errors: Object.fromEntries( + Array.from(this.errors.entries()).map(([k, v]) => [k, v.length]) + ) + }; + } +} \ No newline at end of file diff --git a/test/stressTest/class/roomParticipant.js b/test/stressTest/class/roomParticipant.js new file mode 100644 index 0000000..21cd1f6 --- /dev/null +++ b/test/stressTest/class/roomParticipant.js @@ -0,0 +1,83 @@ +import { io } from "socket.io-client"; + +export class RoomParticipant { + constructor(username, roomName) { + this.username = username; + this.roomName = roomName; + this.socket = null; + this.maxRetries = 3; + this.retryDelay = 1000; + } + + async connectToRoom(baseUrl) { + let retries = 0; + const maxRetries = 2; + const retryDelay = 2000; + + const cleanup = () => { + if (this.socket) { + this.socket.removeAllListeners(); + this.socket.disconnect(); + this.socket = null; + } + }; + + while (retries < maxRetries) { + try { + const socket = io(baseUrl, { + path: `/api/room/${this.roomName}/socket`, + transports: ['websocket'], + timeout: 8000, + reconnection: false, + forceNew: true + }); + + const result = await new Promise((resolve, reject) => { + const timeout = setTimeout(() => { + cleanup(); + reject(new Error('Connection timeout')); + }, 8000); + + socket.on('connect', () => { + clearTimeout(timeout); + this.socket = socket; + this.onConnected(); // Add this line + resolve(socket); + }); + + socket.on('connect_error', (error) => { + clearTimeout(timeout); + cleanup(); + reject(new Error(`Connection error: ${error.message}`)); + }); + + socket.on('error', (error) => { + clearTimeout(timeout); + cleanup(); + reject(new Error(`Socket error: ${error.message}`)); + }); + }); + + return result; + + } catch (error) { + retries++; + if (retries === maxRetries) { + throw error; + } + await new Promise(resolve => setTimeout(resolve, retryDelay)); + } + } + } + + onConnected() { + // To be implemented by child classes + } + + disconnect() { + if (this.socket) { + this.socket.disconnect(); + this.socket = null; + } + } +} \ No newline at end of file diff --git a/test/stressTest/class/student.js b/test/stressTest/class/student.js new file mode 100644 index 0000000..f1696ed --- /dev/null +++ b/test/stressTest/class/student.js @@ -0,0 +1,48 @@ +// student.js +import { RoomParticipant } from './roomParticipant.js'; + +export class Student extends RoomParticipant { + + nbrMessageReceived = 0; + + constructor(username, roomName) { + super(username, roomName); + } + + connectToRoom(baseUrl) { + return super.connectToRoom(baseUrl); + } + + onConnected() { + this.joinRoom(); + this.listenForTeacherMessage(); + } + + joinRoom() { + if (this.socket) { + this.socket.emit('join-room', { + enteredRoomName: this.roomName, + username: this.username + }); + } + } + + listenForTeacherMessage() { + if (this.socket) { + this.socket.on('message-sent-teacher', ({ message }) => { + this.nbrMessageReceived++; + this.respondToTeacher(message); + }); + } + } + + respondToTeacher(message) { + const reply = `${this.username} replying to: "${message}"`; + if (this.socket) { + this.socket.emit('message-from-student', { + roomName: this.roomName, + message: reply + }); + } + } +} \ No newline at end of file diff --git a/test/stressTest/class/teacher.js b/test/stressTest/class/teacher.js new file mode 100644 index 0000000..c6aaa9c --- /dev/null +++ b/test/stressTest/class/teacher.js @@ -0,0 +1,46 @@ +import { RoomParticipant } from './roomParticipant.js'; + +export class Teacher extends RoomParticipant { + + nbrMessageReceived = 0; + + constructor(username, roomName) { + super(username, roomName); + this.ready = false; + } + + connectToRoom(baseUrl) { + return super.connectToRoom(baseUrl); + } + + onConnected() { + this.createRoom(); + this.listenForStudentMessage(); + } + + createRoom() { + if (this.socket) { + this.socket.emit('create-room', this.roomName); + } + } + + broadcastMessage(message) { + if (this.socket) { + this.socket.emit('message-from-teacher', { + roomName: this.roomName, + message + }); + } else { + console.warn(`Teacher ${this.username} not ready to broadcast yet`); + } + } + + listenForStudentMessage() { + if (this.socket) { + this.socket.on('message-sent-student', ({ message }) => { + //console.log(`Teacher ${this.username} received: "${message}"`); + this.nbrMessageReceived++; + }); + } + } +} \ No newline at end of file diff --git a/test/stressTest/class/watcher.js b/test/stressTest/class/watcher.js new file mode 100644 index 0000000..e770e35 --- /dev/null +++ b/test/stressTest/class/watcher.js @@ -0,0 +1,72 @@ +import { RoomParticipant } from './roomParticipant.js'; + +export class Watcher extends RoomParticipant { + + roomRessourcesData = []; + checkRessourceInterval = null; + + constructor(username, roomName) { + super(username, roomName); + } + + connectToRoom(baseUrl) { + return super.connectToRoom(baseUrl); + } + + onConnected() { + this.startCheckingResources(); + } + + checkRessource() { + if (this.socket?.connected) { + try { + this.socket.emit("get-usage"); + this.socket.once("usage-data", (data) => { + const timestamp = Date.now(); + // Store each container's metrics separately with timestamp + data.forEach(containerStat => { + const existingData = this.roomRessourcesData.find(d => d.containerId === containerStat.containerId); + if (existingData) { + existingData.metrics.push({ + timestamp, + ...containerStat + }); + } else { + this.roomRessourcesData.push({ + containerId: containerStat.containerId, + containerName: containerStat.containerName, + metrics: [{ + timestamp, + ...containerStat + }] + }); + } + }); + }); + } catch (error) { + console.warn(`Error capturing metrics for room ${this.roomName}:`, error.message); + } + } + } + + startCheckingResources(intervalMs = 500) { + if (this.checkRessourceInterval) { + console.warn(`Resource checking is already running for room ${this.roomName}.`); + return; + } + + this.checkRessourceInterval = setInterval(() => this.checkRessource(), intervalMs); + } + + stopCheckingResources() { + if (this.checkRessourceInterval) { + clearInterval(this.checkRessourceInterval); + this.checkRessourceInterval = null; + } + } + + disconnect() { + this.stopCheckingResources(); + super.disconnect(); + } +} diff --git a/test/stressTest/docker-compose.yml b/test/stressTest/docker-compose.yml new file mode 100644 index 0000000..51f4707 --- /dev/null +++ b/test/stressTest/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3' + +services: + + stress-test: + build: + context: . + dockerfile: Dockerfile + container_name: stress-test + network_mode: host + env_file: + - .env + volumes: + - ./output:/app/output + tty: true + stdin_open: true \ No newline at end of file diff --git a/test/stressTest/main.js b/test/stressTest/main.js new file mode 100644 index 0000000..e7a06cd --- /dev/null +++ b/test/stressTest/main.js @@ -0,0 +1,201 @@ +import { attemptLoginOrRegister, createRoomContainer } from './utility/apiServices.js'; +import { Student } from './class/student.js'; +import { Teacher } from './class/teacher.js'; +import { Watcher } from './class/watcher.js'; +import { TestMetrics } from './class/metrics.js'; +import dotenv from 'dotenv'; +import generateMetricsReport from './utility/metrics_generator.js'; + +dotenv.config(); + +const config = { + baseUrl: process.env.BASE_URL || 'http://localhost', + auth: { + username: process.env.USER_EMAIL || 'admin@admin.com', + password: process.env.USER_PASSWORD || 'admin' + }, + rooms: { + count: parseInt(process.env.NUMBER_ROOMS || '15'), + usersPerRoom: parseInt(process.env.USERS_PER_ROOM || '60'), + batchSize: parseInt(process.env.BATCH_SIZE || 5), + batchDelay: parseInt(process.env.BATCH_DELAY || 250) + }, + simulation: { + maxMessages: parseInt(process.env.MAX_MESSAGES_ROUND || '20'), + messageInterval: parseInt(process.env.CONVERSATION_INTERVAL || '1000'), + responseTimeout: parseInt(process.env.MESSAGE_RESPONSE_TIMEOUT || 5000) + } +}; + +const rooms = new Map(); +const metrics = new TestMetrics(); + +// Changes to setupRoom function +async function setupRoom(token, index) { + try { + const room = await createRoomContainer(config.baseUrl, token); + if (!room?.id) throw new Error('Room creation failed'); + metrics.roomsCreated++; + + const teacher = new Teacher(`teacher_${index}`, room.id); + // Only create watcher for first room (index 0) + const watcher = index === 0 ? new Watcher(`watcher_${index}`, room.id) : null; + + await Promise.all([ + teacher.connectToRoom(config.baseUrl) + .then(() => metrics.usersConnected++) + .catch(err => { + metrics.userConnectionsFailed++; + metrics.logError('teacherConnection', err); + console.warn(`Teacher ${index} connection failed:`, err.message); + }), + // Only connect watcher if it exists + ...(watcher ? [ + watcher.connectToRoom(config.baseUrl) + .then(() => metrics.usersConnected++) + .catch(err => { + metrics.userConnectionsFailed++; + metrics.logError('watcherConnection', err); + console.warn(`Watcher ${index} connection failed:`, err.message); + }) + ] : []) + ]); + + // Adjust number of students based on whether room has a watcher + const studentCount = watcher ? + config.rooms.usersPerRoom - 2 : // Room with watcher: subtract teacher and watcher + config.rooms.usersPerRoom - 1; // Rooms without watcher: subtract only teacher + + const students = Array.from({ length: studentCount }, + (_, i) => new Student(`student_${index}_${i}`, room.id)); + + rooms.set(room.id, { teacher, watcher, students }); + return room.id; + } catch (err) { + metrics.roomsFailed++; + metrics.logError('roomSetup', err); + console.warn(`Room ${index} setup failed:`, err.message); + return null; + } +} + +async function connectParticipants(roomId) { + const { students } = rooms.get(roomId); + const participants = [...students]; + + for (let i = 0; i < participants.length; i += config.rooms.batchSize) { + const batch = participants.slice(i, i + config.rooms.batchSize); + await Promise.all(batch.map(p => + Promise.race([ + p.connectToRoom(config.baseUrl).then(() => { + metrics.usersConnected++; + }), + new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), 10000)) + ]).catch(err => { + metrics.userConnectionsFailed++; + metrics.logError('studentConnection', err); + console.warn(`Connection failed for ${p.username}:`, err.message); + }) + )); + await new Promise(resolve => setTimeout(resolve, config.rooms.batchDelay)); + } +} + +async function simulate() { + const simulations = Array.from(rooms.entries()).map(async ([roomId, { teacher, students }]) => { + const connectedStudents = students.filter(student => student.socket?.connected); + const expectedResponses = connectedStudents.length; + + for (let i = 0; i < config.simulation.maxMessages; i++) { + metrics.messagesAttempted++; + const initialMessages = teacher.nbrMessageReceived; + + try { + teacher.broadcastMessage(`Message ${i + 1} from ${teacher.username}`); + metrics.messagesSent++; + + await Promise.race([ + new Promise(resolve => { + const checkResponses = setInterval(() => { + const receivedResponses = teacher.nbrMessageReceived - initialMessages; + if (receivedResponses >= expectedResponses) { + metrics.messagesReceived += receivedResponses; + clearInterval(checkResponses); + resolve(); + } + }, 100); + }), + new Promise((_, reject) => + setTimeout(() => reject(new Error('Response timeout')), config.simulation.responseTimeout) + ) + ]); + } catch (error) { + metrics.logError('messaging', error); + console.error(`Error in room ${roomId} message ${i + 1}:`, error); + } + + await new Promise(resolve => setTimeout(resolve, config.simulation.messageInterval)); + } + }); + + await Promise.all(simulations); + console.log('All room simulations completed'); +} + +async function generateReport() { + const watcherRoom = Array.from(rooms.entries()).find(([_, room]) => room.watcher); + if (!watcherRoom) { + throw new Error('No watcher found in any room'); + } + const data = { + [watcherRoom[0]]: watcherRoom[1].watcher.roomRessourcesData + }; + return generateMetricsReport(data, metrics); +} + +function cleanup() { + for (const { teacher, watcher, students } of rooms.values()) { + [teacher, watcher, ...students].forEach(p => p?.disconnect()); + } +} + +async function main() { + try { + const token = await attemptLoginOrRegister(config.baseUrl, config.auth.username, config.auth.password); + if (!token) throw new Error('Authentication failed'); + + console.log('Creating rooms...'); + const roomIds = await Promise.all( + Array.from({ length: config.rooms.count }, (_, i) => setupRoom(token, i)) + ); + + console.log('Connecting participants...'); + await Promise.all(roomIds.filter(Boolean).map(connectParticipants)); + + console.log('Retrieving baseline metrics...'); + await new Promise(resolve => setTimeout(resolve, 10000)); + + console.log('Starting simulation across all rooms...'); + await simulate(); + + console.log('Simulation complete. Waiting for system stabilization...'); + await new Promise(resolve => setTimeout(resolve, 10000)); + + console.log('Generating final report...'); + const folderName = await generateReport(); + console.log(`Metrics report generated in ${folderName.outputDir}`); + + console.log('All done!'); + } catch (error) { + metrics.logError('main', error); + console.error('Error:', error.message); + } finally { + cleanup(); + } +} + +['SIGINT', 'exit', 'uncaughtException', 'unhandledRejection'].forEach(event => { + process.on(event, cleanup); +}); + +main(); \ No newline at end of file diff --git a/test/stressTest/package-lock.json b/test/stressTest/package-lock.json new file mode 100644 index 0000000..ef4433e --- /dev/null +++ b/test/stressTest/package-lock.json @@ -0,0 +1,1230 @@ +{ + "name": "stresstest", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "stresstest", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "axios": "^1.7.7", + "chart.js": "^3.9.1", + "chartjs-node-canvas": "^4.1.6", + "dockerode": "^4.0.2", + "dotenv": "^16.4.5", + "p-limit": "^6.1.0", + "socket.io": "^4.8.1", + "socket.io-client": "^4.8.1" + } + }, + "node_modules/@balena/dockerignore": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@balena/dockerignore/-/dockerignore-1.0.2.tgz", + "integrity": "sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q==" + }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", + "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==", + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, + "node_modules/@socket.io/component-emitter": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", + "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" + }, + "node_modules/@types/cookie": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" + }, + "node_modules/@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "22.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", + "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", + "dependencies": { + "undici-types": "~6.19.8" + } + }, + "node_modules/abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" + }, + "node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "deprecated": "This package is no longer supported.", + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/asn1": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", + "dependencies": { + "safer-buffer": "~2.1.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/base64id": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", + "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==", + "engines": { + "node": "^4.5.0 || >= 5.9" + } + }, + "node_modules/bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==", + "dependencies": { + "tweetnacl": "^0.14.3" + } + }, + "node_modules/bl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "dependencies": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/buildcheck": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/buildcheck/-/buildcheck-0.0.6.tgz", + "integrity": "sha512-8f9ZJCUXyT1M35Jx7MkBgmBMo3oHTTBIPLiY9xyL0pl3T5RwcPEY8cUHr5LBNfu/fk6c2T4DJZuVM/8ZZT2D2A==", + "optional": true, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/canvas": { + "version": "2.11.2", + "resolved": "https://registry.npmjs.org/canvas/-/canvas-2.11.2.tgz", + "integrity": "sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==", + "hasInstallScript": true, + "dependencies": { + "@mapbox/node-pre-gyp": "^1.0.0", + "nan": "^2.17.0", + "simple-get": "^3.0.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/chart.js": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.9.1.tgz", + "integrity": "sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==" + }, + "node_modules/chartjs-node-canvas": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/chartjs-node-canvas/-/chartjs-node-canvas-4.1.6.tgz", + "integrity": "sha512-UQJbPWrvqB/FoLclGA9BaLQmZbzSYlujF4w8NZd6Xzb+sqgACBb2owDX6m7ifCXLjUW5Nz0Qx0qqrTtQkkSoYw==", + "dependencies": { + "canvas": "^2.8.0", + "tslib": "^2.3.1" + }, + "peerDependencies": { + "chart.js": "^3.5.1" + } + }, + "node_modules/chownr": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "bin": { + "color-support": "bin.js" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cors": { + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/cpu-features": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/cpu-features/-/cpu-features-0.0.10.tgz", + "integrity": "sha512-9IkYqtX3YHPCzoVg1Py+o9057a3i0fp7S530UWokCSaFVTc7CwXPRiOjRjBQQ18ZCNafx78YfnG+HALxtVmOGA==", + "hasInstallScript": true, + "optional": true, + "dependencies": { + "buildcheck": "~0.0.6", + "nan": "^2.19.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/decompress-response": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz", + "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==", + "dependencies": { + "mimic-response": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" + }, + "node_modules/detect-libc": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", + "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/docker-modem": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/docker-modem/-/docker-modem-5.0.3.tgz", + "integrity": "sha512-89zhop5YVhcPEt5FpUFGr3cDyceGhq/F9J+ZndQ4KfqNvfbJpPMfgeixFgUj5OjCYAboElqODxY5Z1EBsSa6sg==", + "dependencies": { + "debug": "^4.1.1", + "readable-stream": "^3.5.0", + "split-ca": "^1.0.1", + "ssh2": "^1.15.0" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/dockerode": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/dockerode/-/dockerode-4.0.2.tgz", + "integrity": "sha512-9wM1BVpVMFr2Pw3eJNXrYYt6DT9k0xMcsSCjtPvyQ+xa1iPg/Mo3T/gUcwI0B2cczqCeCYRPF8yFYDwtFXT0+w==", + "dependencies": { + "@balena/dockerignore": "^1.0.2", + "docker-modem": "^5.0.3", + "tar-fs": "~2.0.1" + }, + "engines": { + "node": ">= 8.0" + } + }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "dependencies": { + "once": "^1.4.0" + } + }, + "node_modules/engine.io": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz", + "integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==", + "dependencies": { + "@types/cookie": "^0.4.1", + "@types/cors": "^2.8.12", + "@types/node": ">=10.0.0", + "accepts": "~1.3.4", + "base64id": "2.0.0", + "cookie": "~0.7.2", + "cors": "~2.8.5", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.17.1" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/engine.io-client": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.6.2.tgz", + "integrity": "sha512-TAr+NKeoVTjEVW8P3iHguO1LO6RlUz9O5Y8o7EY0fU+gY1NYqas7NN3slpFtbXEsLMHk0h90fJMfKjRkQ0qUIw==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1", + "engine.io-parser": "~5.2.1", + "ws": "~8.17.1", + "xmlhttprequest-ssl": "~2.1.1" + } + }, + "node_modules/engine.io-parser": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz", + "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==", + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fs-constants": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, + "node_modules/gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "deprecated": "This package is no longer supported.", + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-response": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz", + "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/nan": { + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz", + "integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "deprecated": "This package is no longer supported.", + "dependencies": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/p-limit": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.1.0.tgz", + "integrity": "sha512-H0jc0q1vOzlEk0TqAKXKZxdl7kX3OFUzCnNVUnq5Pc3DGo0kpeaMuPqxQn235HibwBEb0/pm9dgKTjXy66fBkg==", + "dependencies": { + "yocto-queue": "^1.1.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, + "node_modules/pump": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.2.tgz", + "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", + "dependencies": { + "end-of-stream": "^1.1.0", + "once": "^1.3.1" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/simple-get": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.1.tgz", + "integrity": "sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==", + "dependencies": { + "decompress-response": "^4.2.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, + "node_modules/socket.io": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz", + "integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==", + "dependencies": { + "accepts": "~1.3.4", + "base64id": "~2.0.0", + "cors": "~2.8.5", + "debug": "~4.3.2", + "engine.io": "~6.6.0", + "socket.io-adapter": "~2.5.2", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.2.0" + } + }, + "node_modules/socket.io-adapter": { + "version": "2.5.5", + "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz", + "integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==", + "dependencies": { + "debug": "~4.3.4", + "ws": "~8.17.1" + } + }, + "node_modules/socket.io-client": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.8.1.tgz", + "integrity": "sha512-hJVXfu3E28NmzGk8o1sHhN3om52tRvwYeidbj7xKy2eIIse5IoKX3USlS6Tqt3BHAtflLIkCQBkzVrEEfWUyYQ==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.2", + "engine.io-client": "~6.6.1", + "socket.io-parser": "~4.2.4" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/socket.io-parser": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz", + "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==", + "dependencies": { + "@socket.io/component-emitter": "~3.1.0", + "debug": "~4.3.1" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/split-ca": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split-ca/-/split-ca-1.0.1.tgz", + "integrity": "sha512-Q5thBSxp5t8WPTTJQS59LrGqOZqOsrhDGDVm8azCqIBjSBd7nd9o2PM+mDulQQkh8h//4U6hFZnc/mul8t5pWQ==" + }, + "node_modules/ssh2": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/ssh2/-/ssh2-1.16.0.tgz", + "integrity": "sha512-r1X4KsBGedJqo7h8F5c4Ybpcr5RjyP+aWIG007uBPRjmdQWfEiVLzSK71Zji1B9sKxwaCvD8y8cwSkYrlLiRRg==", + "hasInstallScript": true, + "dependencies": { + "asn1": "^0.2.6", + "bcrypt-pbkdf": "^1.0.2" + }, + "engines": { + "node": ">=10.16.0" + }, + "optionalDependencies": { + "cpu-features": "~0.0.10", + "nan": "^2.20.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tar-fs": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.1.tgz", + "integrity": "sha512-6tzWDMeroL87uF/+lin46k+Q+46rAJ0SyPGz7OW7wTgblI273hsBqk2C1j0/xNadNLKDTUL9BukSjB7cwgmlPA==", + "dependencies": { + "chownr": "^1.1.1", + "mkdirp-classic": "^0.5.2", + "pump": "^3.0.0", + "tar-stream": "^2.0.0" + } + }, + "node_modules/tar-stream": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "dependencies": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/tar/node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "engines": { + "node": ">=10" + } + }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==" + }, + "node_modules/tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==" + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, + "node_modules/ws": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xmlhttprequest-ssl": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz", + "integrity": "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "node_modules/yocto-queue": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.1.1.tgz", + "integrity": "sha512-b4JR1PFR10y1mKjhHY9LaGo6tmrgjit7hxVIeAmyMw3jegXR4dhYqLaQF5zMXZxY7tLpMyJeLjr1C4rLmkVe8g==", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + } +} diff --git a/test/stressTest/package.json b/test/stressTest/package.json new file mode 100644 index 0000000..f228a34 --- /dev/null +++ b/test/stressTest/package.json @@ -0,0 +1,22 @@ +{ + "name": "stresstest", + "version": "1.0.0", + "description": "main.js", + "type": "module", + "main": "main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "axios": "^1.7.7", + "chart.js": "^3.9.1", + "chartjs-node-canvas": "^4.1.6", + "dockerode": "^4.0.2", + "dotenv": "^16.4.5", + "p-limit": "^6.1.0", + "socket.io": "^4.8.1", + "socket.io-client": "^4.8.1" + } +} diff --git a/test/stressTest/utility/apiServices.js b/test/stressTest/utility/apiServices.js new file mode 100644 index 0000000..36d8472 --- /dev/null +++ b/test/stressTest/utility/apiServices.js @@ -0,0 +1,77 @@ +import axios from "axios"; + +// Logs in a user. +async function login(baseUrl, email, password) { + if (!email || !password) throw new Error("Email and password are required."); + + try { + const res = await axios.post(`${baseUrl}/api/user/login`, { email, password }, { + headers: { "Content-Type": "application/json" }, + }); + + if (res.status === 200 && res.data.token) { + console.log(`Login successful for ${email}`); + return res.data.token; + } + throw new Error(`Login failed. Status: ${res.status}`); + } catch (error) { + console.error(`Login error for ${email}:`, error.message); + throw error; + } +} + +// Registers a new user. +async function register(baseUrl, email, password) { + if (!email || !password) throw new Error("Email and password are required."); + + try { + const res = await axios.post(`${baseUrl}/api/user/register`, { email, password }, { + headers: { "Content-Type": "application/json" }, + }); + + if (res.status === 200) { + console.log(`Registration successful for ${email}`); + return res.data.message || "Registration completed successfully."; + } + throw new Error(`Registration failed. Status: ${res.status}`); + } catch (error) { + console.error(`Registration error for ${email}:`, error.message); + throw error; + } +} + +// Attempts to log in a user, or registers and logs in if the login fails. +export async function attemptLoginOrRegister(baseUrl, username, password) { + try { + return await login(baseUrl, username, password); + } catch (loginError) { + console.log(`Login failed for ${username}. Attempting registration...`); + try { + await register(baseUrl, username, password); + return await login(baseUrl, username, password); + } catch (registerError) { + console.error(`Registration and login failed for ${username}:`, registerError.message); + return null; + } + } +} + +// Creates a new room +export async function createRoomContainer(baseUrl, token) { + if (!token) throw new Error("Authorization token is required."); + + try { + const res = await axios.post(`${baseUrl}/api/room`, {}, { + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}`, + }, + }); + + if (res.status === 200) return res.data; + throw new Error(`Room creation failed. Status: ${res.status}`); + } catch (error) { + console.error("Room creation error:", error.message); + throw error; + } +} \ No newline at end of file diff --git a/test/stressTest/utility/metrics_generator.js b/test/stressTest/utility/metrics_generator.js new file mode 100644 index 0000000..022ff5b --- /dev/null +++ b/test/stressTest/utility/metrics_generator.js @@ -0,0 +1,253 @@ +import fs from 'fs'; +import path from 'path'; +import { ChartJSNodeCanvas } from 'chartjs-node-canvas'; + +async function saveMetricsSummary(metrics, baseOutputDir) { + const metricsData = metrics.getSummary(); + + // Save as JSON + fs.writeFileSync( + path.join(baseOutputDir, 'metrics-summary.json'), + JSON.stringify(metricsData, null, 2) + ); + + // Save as formatted text + const textSummary = ` +Load Test Summary +================ + +Rooms +----- +Created: ${metricsData.rooms.created} +Failed: ${metricsData.rooms.failed} +Total: ${metricsData.rooms.total} + +Users +----- +Connected: ${metricsData.users.connected} +Failed: ${metricsData.users.failed} +Total: ${metricsData.users.total} + +Messages +-------- +Attempted: ${metricsData.messages.attempted} +Sent: ${metricsData.messages.sent} +Received: ${metricsData.messages.received} + +Errors by Category +---------------- +${Object.entries(metricsData.errors) + .map(([category, count]) => `${category}: ${count}`) + .join('\n')} +`; + + fs.writeFileSync( + path.join(baseOutputDir, 'metrics-summary.txt'), + textSummary.trim() + ); +} + +// Common chart configurations +const CHART_CONFIG = { + width: 800, + height: 400, + chartStyles: { + memory: { + borderColor: 'blue', + backgroundColor: 'rgba(54, 162, 235, 0.2)' + }, + memoryPercent: { + borderColor: 'green', + backgroundColor: 'rgba(75, 192, 192, 0.2)' + }, + cpu: { + borderColor: 'red', + backgroundColor: 'rgba(255, 99, 132, 0.2)' + } + } +}; + +const createBaseChartConfig = (labels, dataset, xLabel, yLabel) => ({ + type: 'line', + data: { + labels, + datasets: [dataset] + }, + options: { + scales: { + x: { title: { display: true, text: xLabel }}, + y: { title: { display: true, text: yLabel }} + }, + plugins: { + legend: { display: true, position: 'top' } + } + } +}); + +function ensureDirectoryExists(directory) { + !fs.existsSync(directory) && fs.mkdirSync(directory, { recursive: true }); +} + +async function generateMetricsChart(chartJSNodeCanvas, data, style, label, timeLabels, metric, outputPath) { + const dataset = { + label, + data: data.map(m => m[metric] || 0), + ...CHART_CONFIG.chartStyles[style], + fill: true, + tension: 0.4 + }; + + const buffer = await chartJSNodeCanvas.renderToBuffer( + createBaseChartConfig(timeLabels, dataset, 'Time', label) + ); + + return fs.promises.writeFile(outputPath, buffer); +} + +async function generateContainerCharts(chartJSNodeCanvas, containerData, outputDir) { + const timeLabels = containerData.metrics.map(m => + new Date(m.timestamp).toLocaleTimeString() + ); + + const chartPromises = [ + generateMetricsChart( + chartJSNodeCanvas, + containerData.metrics, + 'memory', + `${containerData.containerName} Memory (MB)`, + timeLabels, + 'memoryUsedMB', + path.join(outputDir, 'memory-usage-mb.png') + ), + generateMetricsChart( + chartJSNodeCanvas, + containerData.metrics, + 'memoryPercent', + `${containerData.containerName} Memory %`, + timeLabels, + 'memoryUsedPercentage', + path.join(outputDir, 'memory-usage-percent.png') + ), + generateMetricsChart( + chartJSNodeCanvas, + containerData.metrics, + 'cpu', + `${containerData.containerName} CPU %`, + timeLabels, + 'cpuUsedPercentage', + path.join(outputDir, 'cpu-usage.png') + ) + ]; + + await Promise.all(chartPromises); +} + +async function processSummaryMetrics(containers, timeLabels) { + return timeLabels.map((_, timeIndex) => ({ + memoryUsedMB: containers.reduce((sum, container) => + sum + (container.metrics[timeIndex]?.memoryUsedMB || 0), 0), + memoryUsedPercentage: containers.reduce((sum, container) => + sum + (container.metrics[timeIndex]?.memoryUsedPercentage || 0), 0), + cpuUsedPercentage: containers.reduce((sum, container) => + sum + (container.metrics[timeIndex]?.cpuUsedPercentage || 0), 0) + })); +} + +export default async function generateMetricsReport(allRoomsData, testMetrics) { + try { + const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); + const baseOutputDir = `./output/${timestamp}`; + const dirs = [ + baseOutputDir, + path.join(baseOutputDir, 'all-containers'), + path.join(baseOutputDir, 'all-rooms') + ]; + + dirs.forEach(ensureDirectoryExists); + + if (testMetrics) { + await saveMetricsSummary(testMetrics, baseOutputDir); + } + + const chartJSNodeCanvas = new ChartJSNodeCanvas(CHART_CONFIG); + const allContainers = Object.values(allRoomsData).flat(); + const roomContainers = allContainers.filter(c => + c.containerName.startsWith('room_') + ); + + if (allContainers.length > 0) { + const timeLabels = allContainers[0].metrics.map(m => + new Date(m.timestamp).toLocaleTimeString() + ); + const summedMetrics = await processSummaryMetrics(allContainers, timeLabels); + await generateContainerSummaryCharts( + chartJSNodeCanvas, + summedMetrics, + timeLabels, + path.join(baseOutputDir, 'all-containers') + ); + } + + if (roomContainers.length > 0) { + const timeLabels = roomContainers[0].metrics.map(m => + new Date(m.timestamp).toLocaleTimeString() + ); + const summedMetrics = await processSummaryMetrics(roomContainers, timeLabels); + await generateContainerSummaryCharts( + chartJSNodeCanvas, + summedMetrics, + timeLabels, + path.join(baseOutputDir, 'all-rooms') + ); + } + + // Process individual containers + const containerPromises = Object.values(allRoomsData) + .flat() + .filter(container => !container.containerName.startsWith('room_')) + .map(async containerData => { + const containerDir = path.join(baseOutputDir, containerData.containerName); + ensureDirectoryExists(containerDir); + await generateContainerCharts(chartJSNodeCanvas, containerData, containerDir); + }); + + await Promise.all(containerPromises); + + return { outputDir: baseOutputDir }; + } catch (error) { + console.error('Error generating metrics report:', error); + throw error; + } +} + +async function generateContainerSummaryCharts(chartJSNodeCanvas, metrics, timeLabels, outputDir) { + await Promise.all([ + generateMetricsChart( + chartJSNodeCanvas, + metrics, + 'memory', + 'Total Memory (MB)', + timeLabels, + 'memoryUsedMB', + path.join(outputDir, 'total-memory-usage-mb.png') + ), + generateMetricsChart( + chartJSNodeCanvas, + metrics, + 'memoryPercent', + 'Total Memory %', + timeLabels, + 'memoryUsedPercentage', + path.join(outputDir, 'total-memory-usage-percent.png') + ), + generateMetricsChart( + chartJSNodeCanvas, + metrics, + 'cpu', + 'Total CPU %', + timeLabels, + 'cpuUsedPercentage', + path.join(outputDir, 'total-cpu-usage.png') + ) + ]); +} \ No newline at end of file