diff --git a/InfoLogger/.dockerignore b/InfoLogger/.dockerignore new file mode 100644 index 000000000..0deee5cae --- /dev/null +++ b/InfoLogger/.dockerignore @@ -0,0 +1,11 @@ +# Default ignore everything +* + +# Project +!lib/ +!package*.json +!public/ +!index.js +!test/ +!eslint.config.js +!config.js \ No newline at end of file diff --git a/InfoLogger/Dockerfile b/InfoLogger/Dockerfile new file mode 100644 index 000000000..baed0be4b --- /dev/null +++ b/InfoLogger/Dockerfile @@ -0,0 +1,65 @@ +# +# ---- Base ---- +FROM node:22-alpine AS base + +RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app + +# Create app directory +WORKDIR /home/node/app + +# +# ---- Development Dependencies ---- +FROM base AS developmentdependencies + +# Installs Git and packages required for Puppeteer +# https://pkgs.alpinelinux.org/packages +RUN apk add --no-cache \ + chromium \ + freetype \ + freetype-dev + +# Tell Puppeteer to skip installing Chrome. We'll be using the installed package. +ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true +ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser + +# Copy all files, except those ignored by .dockerignore, to the container +COPY package*.json ./ +# Installs modules from package-lock.json if there are changes, this ensures reproducible build +RUN npm --silent ci + + +# +# ---- Development ---- +FROM developmentdependencies AS development + +# Expose the port to the Docker instance (not the host!) +EXPOSE 8080 + +# Run the container as a non-root user 1000:1000, which is the default user in the node:22-alpine image +USER 1000:1000 + +# Run start script as specified in package.json +CMD [ "npm", "run", "start:dev" ] + +# +# ---- Test ---- +FROM developmentdependencies AS test + +# +COPY . . + +USER 1000:1000 + +# Run start script as specified in package.json +CMD [ "npm", "run", "test" ] + +# +# ---- Simul ---- +FROM base AS simul +COPY package.json ./ +COPY test/live-simulator ./test/live-simulator +EXPOSE 6102 + +USER 1000:1000 + +CMD [ "npm", "run", "simul" ] diff --git a/InfoLogger/README.md b/InfoLogger/README.md index 676e37a56..e5917d932 100644 --- a/InfoLogger/README.md +++ b/InfoLogger/README.md @@ -11,6 +11,8 @@ - [Interface User Guide](#interface-user-guide) - [Requirements](#requirements) - [Project Layout](#project-layout) + - [Scripts](#scripts) + - [Docker development](#docker-development) - [Backend](#backend) - [Frontend](#frontend) - [Local Development](#local-development) @@ -55,12 +57,41 @@ Screenshot of the current interface, running locally against a fake InfoLoggerSe ## Requirements - `nodejs` >= `22.x` +- Docker/Docker Compose - InfoLogger MariaDB database for Query mode - InfoLoggerServer endpoint for Live mode ## Project Layout ILG is a Node.js API Gateway and Single-Page Application built on top of the `@aliceo2/web-ui` framework. It serves as a unified interface to two separate operational backends: a **MariaDB database** for historical queries and an **InfoLoggerServer TCP endpoint** for live log streaming. +## Scripts +| Script | Description | +| --- | --- | +| `npm start` | Run the app (`node index.js`). | +| `npm run lint` | Lint the project with ESLint. | +| `npm run lint:fix` | Lint and automatically fix fixable problems. | +| `npm test` | Run the linter, then the Mocha test suite. | +| `npm run coverage` | Run the test suite under `nyc` and generate the coverage report. | +| `npm run coverage:report` | Generate HTML + JSON coverage reports under `coverage/` from the last run. | + +Docker commands (`docker:dev`, `docker:dev:local-live`, `docker:dev:local-query`, `docker:dev:local-both`, `docker:test` and `docker:cleanup`) are documented under [Docker development](#docker-development). + +### Docker development + +The development and test docker image will take up about 1.35 GB, about 50% of that is due to puppeteer's chromium requirement, the same reason why Electron apps are so big. + +`database` and `simulator` are behind Compose profiles, so they only start when you ask for them. Rather than typing `--profile` flags by hand, use one of: + +| Script | Application | Database | Simulator | +| --- | --- | --- | --- | +| `npm run docker:dev` | ✅ | ❌ | ❌ | +| `npm run docker:dev:local-live` | ✅ | ❌ | ✅ | +| `npm run docker:dev:local-query` | ✅ | ✅ | ❌ | +| `npm run docker:dev:local-both` | ✅ | ✅ | ✅ | + +For services with a cross, point `config.js` at a remote host and port. For services with a checkmark, the script will start a local container for you. + +Run `npm run docker:cleanup` to remove all containers created by the above and their data. ## Backend @@ -93,72 +124,34 @@ cp config-default.js config.js Edit `config.js` for the setup you're using below. -`npm run dev` runs the backend under nodemon. The frontend has no hot reload - refresh the browser to pick up changes. - ### Query & Live mode Against a remote backend (e.g. a staging instance) -1. Point `mysql` and `infoLoggerServer` in `config.js` at the remote host and port. -2. `npm start`, then open [http://localhost:8080](http://localhost:8080). +1. Point `mysql` and `infoLoggerServer` in `config.js` at a remote host and port. Ask your team for the correct values if you don't have them. +2. `npm run docker:dev`, then open [http://localhost:8080](http://localhost:8080). ### Live mode against synthetic logs (thoroughly test Live mode) The bundled [fake InfoLoggerServer](test/live-simulator/) emits a log every 0-100 ms, shuffling through [test/live-simulator/fakeData.json](test/live-simulator/fakeData.json). -1. Set `infoLoggerServer` in `config.js` to `localhost:6102`. -2. Terminal 1: `npm run simul`. -3. Terminal 2: `npm run dev`. -4. Open [http://localhost:8080](http://localhost:8080) and click **Live**. +1. Point `infoLoggerServer` in `config.js` at `simulator`. +2. `npm run docker:dev:local-live`. +3. Open [http://localhost:8080](http://localhost:8080) and click **Live**. ### Query against a local DB -Requires [Docker Desktop](https://www.docker.com/products/docker-desktop/). - -1. In a working dir, create `compose.yaml`: - - ```yaml - services: - mariadb: - image: mariadb - restart: unless-stopped - ports: ['3306:3306'] - environment: - MARIADB_ROOT_PASSWORD: root # this is just an example, not intended to be a production configuration - phpmyadmin: - image: phpmyadmin - restart: unless-stopped - ports: ['9090:80'] - environment: - - PMA_HOST=mariadb - ``` - - Gives you a MariaDB server with phpMyAdmin on the latest image. Pin a specific version (e.g. `mariadb:11.5`) by changing the `image:` tag. - -2. `docker compose up -d`. -3. Open [http://localhost:9090/](http://localhost:9090/) → log in `root` / `root` → **New** → create database `INFOLOGGER`. -4. Open the **SQL** tab, paste [docs/database-specs.sql](docs/database-specs.sql), click **Go**. -5. In `config.js`: - - ```js - mysql: { - host: '127.0.0.1', - user: 'root', - password: 'root', - database: 'INFOLOGGER', - port: 3306, - timeout: 60000, - retryMs: 5000, - }, - ``` - -6. `npm run dev` - startup should log `Connection to DB successfully established: 127.0.0.1:3306`. +1. Point `mysql` in `config.js` at `database`. +2. `npm run docker:dev:local-query`. +3. Open [http://localhost:8080](http://localhost:8080) and click **Query**. + +Need both at once? `npm run docker:dev:local-both` starts the simulator and the local DB together. ## Testing -- `npm test` - eslint + mocha. `npm run mocha` runs the suite alone. +- `npm run docker:test` - eslint + mocha. - Backend tests: [test/lib/](test/lib). - Frontend tests: [test/public/](test/public). - Add or update the matching test when fixing a bug. -- `npm run eslint` - config in [eslint.config.js](eslint.config.js). Lint failures block CI. +- Lint failures block CI. ### Integration tests (live elsewhere) diff --git a/InfoLogger/config-default.js b/InfoLogger/config-default.js index dbf38c686..b02a218b1 100644 --- a/InfoLogger/config-default.js +++ b/InfoLogger/config-default.js @@ -28,7 +28,7 @@ module.exports = { // optional data source, comment object if not used // all options: https://github.com/mysqljs/mysql#connection-options mysql: { - host: '127.0.0.1', + host: process.env.mariadb_host ?? '127.0.0.1', user: 'root', password: 'root', database: 'INFOLOGGER', @@ -40,7 +40,7 @@ module.exports = { // optional data source, comment object if not used // all options: https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener infoLoggerServer: { - host: 'localhost', + host: process.env.infologger_host ?? 'localhost', port: 6102, }, logging: { diff --git a/InfoLogger/docker-compose.dev.yaml b/InfoLogger/docker-compose.dev.yaml new file mode 100644 index 000000000..a6abf0805 --- /dev/null +++ b/InfoLogger/docker-compose.dev.yaml @@ -0,0 +1,78 @@ +services: + application: + build: + target: development + + restart: "no" + + depends_on: + database: + condition: service_healthy + required: false + simulator: + condition: service_started + required: false + + environment: + NODE_ENV: development + + ports: + - "8080:8080" + + volumes: + - type: bind + read_only: true + source: ./lib + target: /home/node/app/lib + - type: bind + read_only: true + source: ./public + target: /home/node/app/public + - type: bind + read_only: true + source: ./config.js + target: /home/node/app/config.js + - type: bind + read_only: true + source: ./index.js + target: /home/node/app/index.js + + database: + image: mariadb:11.6.2 + restart: unless-stopped + + environment: + MYSQL_ROOT_PASSWORD: ilPwdB + MYSQL_USER: infoBrowser + MYSQL_PASSWORD: ilPwdB + MYSQL_DATABASE: INFOLOGGER + + # should you want to access the DB using a external program + ports: + - "3306:3306" + + # MariaDB re-applies INFOLOGGER.sql each time (throwaway dev database). + volumes: + - type: bind + read_only: true + source: ./docker/INFOLOGGER.sql + target: /docker-entrypoint-initdb.d/INFOLOGGER.sql + + healthcheck: + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + interval: 5s + timeout: 20s + retries: 20 + + profiles: ['local-db'] + + simulator: + build: + target: simul + + restart: "unless-stopped" + + ports: + - "6102:6102" + + profiles: ['local-ilg'] diff --git a/InfoLogger/docker-compose.test.yaml b/InfoLogger/docker-compose.test.yaml new file mode 100644 index 000000000..fbd7521ea --- /dev/null +++ b/InfoLogger/docker-compose.test.yaml @@ -0,0 +1,9 @@ +services: + application: + build: + target: test + + restart: "no" + + environment: + NODE_ENV: development diff --git a/InfoLogger/docker-compose.yaml b/InfoLogger/docker-compose.yaml new file mode 100644 index 000000000..65e53fe27 --- /dev/null +++ b/InfoLogger/docker-compose.yaml @@ -0,0 +1,5 @@ +services: + application: + build: + context: . + dockerfile: Dockerfile diff --git a/InfoLogger/docker/INFOLOGGER.sql b/InfoLogger/docker/INFOLOGGER.sql new file mode 100644 index 000000000..4b33964d9 --- /dev/null +++ b/InfoLogger/docker/INFOLOGGER.sql @@ -0,0 +1,87 @@ +-- phpMyAdmin SQL Dump +-- version 5.2.1 +-- https://www.phpmyadmin.net/ +-- +-- Host: mariadb +-- Generation Time: Dec 15, 2024 at 02:28 PM +-- Server version: 11.5.2-MariaDB-ubu2404 +-- PHP Version: 8.2.25 + +SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; +START TRANSACTION; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; + +-- +-- Database: `INFOLOGGER` +-- +CREATE DATABASE IF NOT EXISTS `INFOLOGGER` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; +USE `INFOLOGGER`; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `messages` +-- + +CREATE TABLE `messages` ( + `severity` char(1) DEFAULT NULL, + `level` tinyint(3) UNSIGNED DEFAULT NULL, + `timestamp` double(16,6) DEFAULT NULL, + `hostname` varchar(32) DEFAULT NULL, + `rolename` varchar(32) DEFAULT NULL, + `pid` smallint(5) UNSIGNED DEFAULT NULL, + `username` varchar(32) DEFAULT NULL, + `system` varchar(32) DEFAULT NULL, + `facility` varchar(32) DEFAULT NULL, + `detector` varchar(32) DEFAULT NULL, + `partition` varchar(32) DEFAULT NULL, + `dest` varchar(32) DEFAULT NULL, + `run` int(10) UNSIGNED DEFAULT NULL, + `errcode` int(10) UNSIGNED DEFAULT NULL, + `errline` smallint(5) UNSIGNED DEFAULT NULL, + `errsource` varchar(32) DEFAULT NULL, + `message` text DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +PARTITION BY HASH (`timestamp` DIV 86400) +PARTITIONS 365; + +-- +-- Dumping data for table `messages` +-- + +INSERT INTO `messages` (`severity`, `level`, `timestamp`, `hostname`, `rolename`, `pid`, `username`, `system`, `facility`, `detector`, `partition`, `dest`, `run`, `errcode`, `errline`, `errsource`, `message`) VALUES +('I', 6, 1456134840.001504, 'aldaqecs01-v1', NULL, 2733, 'alicedaq', 'DAQ', 'LHCBeamInfo', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'Mon Feb 22 10:54:00 2016 (1456134840): BeamMode: NO BEAM; BeamType: ; ParticleTypeB1: ; ParticleTypeB2: ; BetaStar: ; Eng: 0 GeV; FillN: -999; FillScheme: ; NbunchesInt: 0; NbunchesNotIntB1: 0; NbunchesNotIntB2: 0; InteracIst I(B1): 0; InteracTot I(B1): 0; InteracIst I(B2): 0; InteracTot I(B2): 0; NotInteracIst I(B1): 0; NotInteracTot I(B1): 0; NotInteracIst I(B2): 0; NotInteracTot I(B2): 0; PostMortemN: 1; LHCAdjust: STANDBY; LHCBeamDump: STANDBY; LHCInjection: STANDBY; DIPconnected Flag: 1 1 1 1 1 1 1 1 1 1 1 1 1 1'); + +-- +-- Indexes for dumped tables +-- + +-- +-- Indexes for table `messages` +-- +ALTER TABLE `messages` + ADD KEY `ix_severity` (`severity`), + ADD KEY `ix_level` (`level`), + ADD KEY `ix_timestamp` (`timestamp`), + ADD KEY `ix_hostname` (`hostname`(14)), + ADD KEY `ix_rolename` (`rolename`(20)), + ADD KEY `ix_system` (`system`(3)), + ADD KEY `ix_facility` (`facility`(20)), + ADD KEY `ix_detector` (`detector`(8)), + ADD KEY `ix_partition` (`partition`(10)), + ADD KEY `ix_dest` (`dest`(10)), + ADD KEY `ix_run` (`run`), + ADD KEY `ix_errcode` (`errcode`), + ADD KEY `ix_errline` (`errline`), + ADD KEY `ix_errsource` (`errsource`(20)); +COMMIT; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/InfoLogger/eslint.config.js b/InfoLogger/eslint.config.js index 7d58ac2f6..902af3269 100644 --- a/InfoLogger/eslint.config.js +++ b/InfoLogger/eslint.config.js @@ -18,6 +18,14 @@ const jsdoc = require('eslint-plugin-jsdoc'); const stylisticJs = require('@stylistic/eslint-plugin'); module.exports = [ + { + ignores: [ + 'test/', + 'node_modules/', + 'tmp/', + 'nyc_output/', + ], + }, jsdoc.configs['flat/recommended'], pluginJs.configs.recommended, { diff --git a/InfoLogger/package-lock.json b/InfoLogger/package-lock.json index 2e84cb54b..fb7369b6d 100644 --- a/InfoLogger/package-lock.json +++ b/InfoLogger/package-lock.json @@ -22,6 +22,7 @@ "eslint-plugin-jsdoc": "63.3.1", "globals": "17.8.0", "mocha": "11.7.0", + "nodemon": "^3.1.14", "nyc": "18.0.0", "puppeteer": "25.4.0", "sinon": "22.1.0" @@ -1250,6 +1251,33 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/anymatch/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/append-transform": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", @@ -1318,6 +1346,19 @@ "node": ">=6.0.0" } }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/body-parser": { "version": "1.20.5", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.5.tgz", @@ -1383,6 +1424,19 @@ "node": "18 || 20 || >=22" } }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", @@ -2345,6 +2399,19 @@ "node": ">=16.0.0" } }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/finalhandler": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", @@ -2504,6 +2571,21 @@ } ] }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -2849,6 +2931,13 @@ "node": ">= 4" } }, + "node_modules/ignore-by-default": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", + "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", + "dev": true, + "license": "ISC" + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -2884,6 +2973,19 @@ "node": ">= 0.10" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -2914,6 +3016,16 @@ "node": ">=0.10.0" } }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", @@ -3717,6 +3829,132 @@ "node": ">=18" } }, + "node_modules/nodemon": { + "version": "3.1.14", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.14.tgz", + "integrity": "sha512-jakjZi93UtB3jHMWsXL68FXSAosbLfY0In5gtKq3niLSkrWznrVBzXFNOEMJUfc9+Ke7SHWoAZsiMkNP3vq6Jw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.2", + "debug": "^4", + "ignore-by-default": "^1.0.1", + "minimatch": "^10.2.1", + "pstree.remy": "^1.1.8", + "semver": "^7.5.3", + "simple-update-notifier": "^2.0.0", + "supports-color": "^5.5.0", + "touch": "^3.1.0", + "undefsafe": "^2.0.5" + }, + "bin": { + "nodemon": "bin/nodemon.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/nodemon" + } + }, + "node_modules/nodemon/node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/nodemon/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/nodemon/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/nodemon/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/nodemon/node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/nodemon/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/nyc": { "version": "18.0.0", "resolved": "https://registry.npmjs.org/nyc/-/nyc-18.0.0.tgz", @@ -4350,6 +4588,13 @@ "node": ">= 0.10" } }, + "node_modules/pstree.remy": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", + "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", + "dev": true, + "license": "MIT" + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -4824,6 +5069,19 @@ "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true }, + "node_modules/simple-update-notifier": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", + "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/sinon": { "version": "22.1.0", "resolved": "https://registry.npmjs.org/sinon/-/sinon-22.1.0.tgz", @@ -5093,6 +5351,19 @@ "inBundle": true, "license": "MIT" }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, "node_modules/to-valid-identifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/to-valid-identifier/-/to-valid-identifier-1.0.0.tgz", @@ -5120,6 +5391,16 @@ "node": ">=0.6" } }, + "node_modules/touch": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", + "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", + "dev": true, + "license": "ISC", + "bin": { + "nodetouch": "bin/nodetouch.js" + } + }, "node_modules/triple-beam": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", @@ -5191,6 +5472,13 @@ "is-typedarray": "^1.0.0" } }, + "node_modules/undefsafe": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", + "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", + "dev": true, + "license": "MIT" + }, "node_modules/undici-types": { "version": "6.19.8", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", diff --git a/InfoLogger/package.json b/InfoLogger/package.json index f38a3b233..0eca6d081 100644 --- a/InfoLogger/package.json +++ b/InfoLogger/package.json @@ -18,14 +18,21 @@ }, "homepage": "https://alice-o2-project.web.cern.ch/", "scripts": { + "lint": "eslint --config eslint.config.js", + "lint:fix": "npm run lint -- --fix", + "test": "npm run lint && npm run mocha", + "mocha": "mocha --exit $(find test -name 'mocha-*.js')", + "coverage": "nyc npm test && npm run coverage:report", + "coverage:report": "nyc report --reporter=html --reporter=json", "start": "node index.js", - "test": "npm run eslint && npm run mocha", - "dev": "nodemon --inspect --watch index.js --watch lib --watch config.js index.js", + "start:dev": "nodemon --inspect --watch index.js --watch lib --watch config.js index.js", "simul": "node test/live-simulator/runInfoLoggerServer.js", - "eslint": "./node_modules/.bin/eslint --config eslint.config.js lib/ public/", - "mocha": "mocha --exit $(find test -name 'mocha-*.js')", - "coverage": "npm run eslint && nyc npm run mocha", - "coverage-local": "nyc --reporter=lcov npm run mocha" + "docker:dev": "docker compose -f docker-compose.yaml -f docker-compose.dev.yaml up --build", + "docker:dev:local-live": "docker compose -f docker-compose.yaml -f docker-compose.dev.yaml --profile local-ilg up --build", + "docker:dev:local-query": "docker compose -f docker-compose.yaml -f docker-compose.dev.yaml --profile local-db up --build", + "docker:dev:local-both": "docker compose -f docker-compose.yaml -f docker-compose.dev.yaml --profile local-db --profile local-ilg up --build", + "docker:test": "docker compose -f docker-compose.yaml -f docker-compose.test.yaml up --build --abort-on-container-exit --exit-code-from application", + "docker:cleanup": "docker compose -f docker-compose.yaml -f docker-compose.dev.yaml -f docker-compose.test.yaml down -v --remove-orphans" }, "main": "index.js", "dependencies": { @@ -39,6 +46,7 @@ "eslint-plugin-jsdoc": "63.3.1", "globals": "17.8.0", "mocha": "11.7.0", + "nodemon": "^3.1.14", "nyc": "18.0.0", "puppeteer": "25.4.0", "sinon": "22.1.0" diff --git a/InfoLogger/test/lib/mocha-json-db.js b/InfoLogger/test/lib/mocha-json-db.js index 38205ec32..c29a7153c 100644 --- a/InfoLogger/test/lib/mocha-json-db.js +++ b/InfoLogger/test/lib/mocha-json-db.js @@ -16,8 +16,9 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); const JsonFileConnector = require('../../lib/JSONFileConnector.js'); +const { tmpdir } = require('os'); -const CONFIG_FILE = path.join(__dirname, 'db.json.temp'); +const CONFIG_FILE = path.join(tmpdir(), 'db.json.temp'); const TEST_CONTENT = { colsHeader: { diff --git a/InfoLogger/test/test-config.js b/InfoLogger/test/test-config.js index 885acf844..601c1aee5 100644 --- a/InfoLogger/test/test-config.js +++ b/InfoLogger/test/test-config.js @@ -12,6 +12,9 @@ * or submit itself to any jurisdiction. */ +const { tmpdir } = require('os'); +const path = require('path'); + module.exports = { http: { port: 8080, @@ -33,5 +36,5 @@ module.exports = { expiration: '60s', maxAge: '2', }, - dbFile: './test/testdb.json', + dbFile: path.join(tmpdir(), 'testdb.json'), };