Skip to content

Commit d1abfd4

Browse files
committed
browser-emulator: fix metricbeat config path not found
1 parent f6e6dd4 commit d1abfd4

5 files changed

Lines changed: 68 additions & 6 deletions

File tree

browser-emulator/docker-compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
DISABLE_HTTPS: ${DISABLE_HTTPS:-true}
1717
MEDIAFILES_HOST_DIR: ${MEDIAFILES_HOST_DIR:-${PWD}/mediafiles}
1818
SCRIPTS_LOGS_HOST_DIR: ${SCRIPTS_LOGS_HOST_DIR:-${PWD}/logs}
19-
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/browser-emulator/src/assets/metricbeat-config/metricbeat.yml}
19+
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/src/assets/metricbeat-config/metricbeat.yml}
2020
# Set DOCKER_DEBUG=true to enable Node inspector on port 9229
2121
DOCKER_DEBUG: ${DOCKER_DEBUG:-false}
2222
stop_grace_period: 60s

browser-emulator/docker-compose.test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
DOCKER_NETWORK_NAME: browseremulator
1717
DOCKER_BROWSER_EMULATOR_HOST: browser-emulator-tests
1818
MEDIAFILES_HOST_DIR: ${MEDIAFILES_HOST_DIR:-${PWD}/mediafiles}
19-
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/browser-emulator/src/assets/metricbeat-config/metricbeat.yml}
19+
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/src/assets/metricbeat-config/metricbeat.yml}
2020
SCRIPTS_LOGS_HOST_DIR: ${SCRIPTS_LOGS_HOST_DIR:-${PWD}/logs}
2121
# Set DOCKER_DEBUG=true to enable Node inspector on port 9229
2222
DOCKER_DEBUG: ${DOCKER_DEBUG:-false}
@@ -36,7 +36,7 @@ services:
3636
- /var/run/docker.sock:/var/run/docker.sock
3737
# Override the container command to enable optional debugging
3838
# When DOCKER_DEBUG=true the app starts with the Node inspector
39-
command: sh -lc "if [ \"${DOCKER_DEBUG:-false}\" = \"true\" ]; then pnpm run test --inspect-brk=0.0.0.0:9229 --no-file-parallelism tests/e2e/emulated-browsers.test.ts; else pnpm run test; fi"
39+
command: sh -lc "if [ \"${DOCKER_DEBUG:-false}\" = \"true\" ]; then pnpm run test --inspect-brk=0.0.0.0:9229 --no-file-parallelism tests/e2e/emulated-browsers.test.ts; else pnpm run test:coverage; fi"
4040
networks:
4141
browseremulator:
4242
name: browseremulator

browser-emulator/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
DOCKER_BROWSER_EMULATOR_HOST: browser-emulator
1616
MEDIAFILES_HOST_DIR: ${MEDIAFILES_HOST_DIR:-${PWD}/mediafiles}
1717
SCRIPTS_LOGS_HOST_DIR: ${SCRIPTS_LOGS_HOST_DIR:-${PWD}/logs}
18-
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/browser-emulator/src/assets/metricbeat-config/metricbeat.yml}
18+
METRICBEAT_CONFIG: ${METRICBEAT_CONFIG:-${PWD}/src/assets/metricbeat-config/metricbeat.yml}
1919
DISABLE_HTTPS: ${DISABLE_HTTPS:-false}
2020
stop_grace_period: 60s
2121
ports:

browser-emulator/prepare_scripts/install_base.sh

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
# Shell setup, assumes running on Ubuntu 24.04 able to build and install v4l2loopback module
3+
# Shell setup, assumes running on Ubuntu 24.04
44
# ====================================================
55

66
# Trace all commands.
@@ -15,6 +15,43 @@ fi
1515

1616
SELF_PATH="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd -P)" # Absolute canonical path
1717

18+
# Resolve absolute defaults for host directories and metricbeat config
19+
DEFAULT_MEDIAFILES_HOST_DIR="${MEDIAFILES_HOST_DIR:-$SELF_PATH/mediafiles}"
20+
DEFAULT_SCRIPTS_LOGS_HOST_DIR="${SCRIPTS_LOGS_HOST_DIR:-$SELF_PATH/logs}"
21+
DEFAULT_METRICBEAT_CONFIG="${METRICBEAT_CONFIG:-$SELF_PATH/src/assets/metricbeat-config/metricbeat.yml}"
22+
23+
# Export variables so the rest of the script and subsequent shells use them
24+
export MEDIAFILES_HOST_DIR="$DEFAULT_MEDIAFILES_HOST_DIR"
25+
export SCRIPTS_LOGS_HOST_DIR="$DEFAULT_SCRIPTS_LOGS_HOST_DIR"
26+
export METRICBEAT_CONFIG="$DEFAULT_METRICBEAT_CONFIG"
27+
28+
# Ensure directories and metricbeat config directory exist
29+
mkdir -p "$MEDIAFILES_HOST_DIR" "$SCRIPTS_LOGS_HOST_DIR" "$(dirname "$METRICBEAT_CONFIG")"
30+
31+
# Persist environment variables across reboots (interactive shells and system-wide)
32+
PROFILE_D=/etc/profile.d
33+
ENV_FILE=/etc/environment
34+
35+
cat > "$PROFILE_D/openvidu-loadtest.sh" <<EOF
36+
# OpenVidu Loadtest browser emulator environment variables
37+
export MEDIAFILES_HOST_DIR="$MEDIAFILES_HOST_DIR"
38+
export SCRIPTS_LOGS_HOST_DIR="$SCRIPTS_LOGS_HOST_DIR"
39+
export METRICBEAT_CONFIG="$METRICBEAT_CONFIG"
40+
EOF
41+
chmod 644 "$PROFILE_D/openvidu-loadtest.sh"
42+
43+
# Ensure /etc/environment contains the variables (key="value" format)
44+
touch "$ENV_FILE"
45+
for VAR in MEDIAFILES_HOST_DIR SCRIPTS_LOGS_HOST_DIR METRICBEAT_CONFIG; do
46+
VALUE="$(eval echo "\$$VAR")"
47+
if grep -q "^$VAR=" "$ENV_FILE" 2>/dev/null; then
48+
sed -i "s|^$VAR=.*|$VAR=\"$VALUE\"|" "$ENV_FILE"
49+
else
50+
echo "$VAR=\"$VALUE\"" >> "$ENV_FILE"
51+
fi
52+
done
53+
54+
1855
## Install necessary packages
1956
apt-get update
2057
apt-get upgrade -yq

browser-emulator/src/services/config.service.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,41 @@ export class ConfigService {
180180
private logConfiguration(): void {
181181
console.log('Configuration loaded:');
182182
console.log(` SERVER_PORT: ${this.serverPort}`);
183+
console.log(` WEBSOCKET_SERVER_PORT: ${this.websocketServerPort}`);
183184
console.log(` COM_MODULE: ${this.comModule}`);
184185
console.log(` RUNNING_IN_DOCKER: ${this.runningInDocker}`);
185186
console.log(
186187
` DOCKERIZED_BROWSERS: ${this.shouldUseDockerizedBrowsers()}`,
187188
);
189+
console.log(' DOCKERIZED_BROWSERS_CONFIG:');
190+
console.log(` enabled: ${this.dockerizedBrowsersConfig.enabled}`);
191+
console.log(
192+
` networkName: ${this.dockerizedBrowsersConfig.networkName}`,
193+
);
194+
console.log(
195+
` browserEmulatorHost: ${this.dockerizedBrowsersConfig.browserEmulatorHost}`,
196+
);
197+
console.log(
198+
` chromeImage: ${this.dockerizedBrowsersConfig.chromeImage}`,
199+
);
200+
console.log(
201+
` firefoxImage: ${this.dockerizedBrowsersConfig.firefoxImage}`,
202+
);
203+
console.log(
204+
` seleniumPort: ${this.dockerizedBrowsersConfig.seleniumPort}`,
205+
);
206+
console.log(
207+
` startupTimeoutMs: ${this.dockerizedBrowsersConfig.startupTimeoutMs}`,
208+
);
188209
if (this.disableHttps) {
189-
console.log(` DISABLE_HTTP: ${this.disableHttps}`);
210+
console.log(` DISABLE_HTTPS: ${this.disableHttps}`);
190211
}
191212
console.log(` MEDIAFILES_HOST_DIR: ${this.mediaFilesHostDir}`);
192213
console.log(` SCRIPTS_LOGS_HOST_DIR: ${this.scriptsLogsHostDir}`);
214+
console.log(` METRICBEAT_CONFIG: ${this.metricbeatConfig}`);
215+
console.log(
216+
` BROWSER_EMULATOR_HOST_FOR_BROWSERS: ${this.getBrowserEmulatorHostForBrowsers()}`,
217+
);
193218

194219
if (this.legacyMode) {
195220
console.log(' LEGACY_MODE: enabled');

0 commit comments

Comments
 (0)