Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Improved env vars usage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkonst committed Aug 25, 2023
1 parent 50b575a commit 89c627e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 87 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ git clone [email protected]:netology-group/node-wrtc-agent.git
cd node-wrtc-agent
npm i

# macOS
npm run copy-module-darwin
# or linux
npm run copy-module-linux

sudo npm link
```

Expand All @@ -36,7 +31,7 @@ Options:
--turn-username TURN username [string] [required]
-u, --uri MQTT broker URI [string] [required]
--vc, --video-codec Codec name for video (SDP)
[string] [choices: "H264", "VP8", "VP9"] [default: "H264"]
[string] [choices: "VP8", "VP9"] [default: "VP8"]
--help Show help [boolean]
```

Expand Down
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ const { argv } = require('yargs')
},
'vc': {
alias: 'video-codec',
choices: ['H264', 'VP8', 'VP9'],
default: 'H264',
choices: ['VP8', 'VP9'],
default: 'VP8',
description: 'Codec name for video (SDP)',
type: 'string'
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ulms/wrtc-agent",
"version": "0.2.2",
"version": "0.3.0",
"description": "WebRTC agent for load testing",
"main": "cli.js",
"bin": {
Expand Down
99 changes: 44 additions & 55 deletions scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,65 +1,54 @@
#!/usr/bin/env bash

index=$1
n=$2
room=$3
SLEEP_SECONDS="${4:-1}"

users=(
Z2lkOi8vc3RvZWdlL0FkbWluLzc4Ng==.usr.foxford.ru
Z2lkOi8vc3RvZWdlL0FkbWluLzc4Nw==.usr.foxford.ru
Z2lkOi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GxMMEZrYldsdUx6YzVNZz09IiwiZXhwIjoxNjkyNzg2ODkyfQ.e7kExQOkJAGJxqvdCJw5aP3jhNdwT2A5jSxh0FZ6tyAsWGHm5m_TIkNU3zDrGSo-r2wUAUeDVZl7AarsmIKqlg
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJpYW0uc3ZjLmZveGZvcmQucnUiLCJhdWQiOiJ1c3IuZm94Zm9yZC5ydSIsInN1YiI6IloybGtPaTh2YzNSdlpXZGxMMEZrYldsdUx6YzVNdz09IiwiZXhwIjoxNjkyNzg2ODkyfQ.JyPprGkQPnatCf-4nXYIVDMalPZvXuJpXhV0eNch1cBuyK2syeAd4b2H3_aMHIMryhfTychqMnUdXKPcc8YCNw
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJpYW0uc3ZjLmZveGZvcmQucnUiLCJhdWQiOiJ1c3IuZm94Zm9yZC5ydSIsInN1YiI6IloybGtPaTh2YzNSdlpXZGxMMEZrYldsdUx6YzVOQT09IiwiZXhwIjoxNjkyNzg2ODkyfQ.6Rv5Nax2VZsmEAwXJTHlDhWr1iFCIyMQ5sRofaN4c11ShJXyr9JMzlehQ36Si4d8VSDC0mcs_H7nCJlOywttrg
eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJpYW0uc3ZjLmZveGZvcmQucnUiLCJhdWQiOiJ1c3IuZm94Zm9yZC5ydSIsInN1YiI6IloybGtPaTh2YzNSdlpXZGxMMEZrYldsdUx6YzVOUT09IiwiZXhwIjoxNjkyNzg2ODkyfQ.ZDeI-XCPy34sSX40jMiEJZlaBfMqUTPLvs9RzjmgWhI-TIqrK0vposuTvG1a7Sd348Nv_BLQmGZVtT7pTG8YCw
)

BROKER_URI=wss://mqtt-s01-webinar-foxford.dev.netology-group.services/mqtt
CONFERENCE_API_ENDPOINT=https://dev.netology-group.services/s01/webinar-foxford/conference/api/v1
CONFERENCE_APP_NAME=conference.svc.netology-group.services
CONFERENCE_ROOM_ID=$room
STUN_URL=stun:turn.staging01.svc.netology-group.services:3478
#TELEMETRY_APP_NAME=test123
TURN_URL=turn:turn.staging01.svc.netology-group.services:3478
TURN_USERNAME=ntg
TURN_PASSWORD=password
VIDEO_CODEC=VP8

for (( i=0; i<$n; i++ ))
## Usage
#
# Parameters:
# N_AGENTS | {number} | *required* | Number of agents to spawn
# CONFERENCE_ROOM_ID | {uuid} | *required* | Room ID for Conference service
# SLEEP_SECONDS | {number} | optional | Agent start interval (default - 1s)
#
# Example:
# bash scripts/run.sh {N_AGENTS} {CONFERENCE_ROOM_ID} [{SLEEP_SECONDS}]
# bash scripts/run.sh 250 f17d64bc-ceaa-4563-8c2e-432de7bfe91b 0.2

if [[ ! "${ACCESS_TOKEN}" ]]; then echo "ACCESS_TOKEN is required." 1>&2; exit 1; fi
if [[ ! "${ACCOUNT_ID}" ]]; then echo "ACCOUNT_ID is required." 1>&2; exit 1; fi
if [[ ! "${CONFERENCE_API_ENDPOINT}" ]]; then echo "CONFERENCE_API_ENDPOINT is required." 1>&2; exit 1; fi
if [[ ! "${CONFERENCE_APP_NAME}" ]]; then echo "CONFERENCE_APP_NAME is required." 1>&2; exit 1; fi
if [[ ! "${MQTT_BROKER_URI}" ]]; then echo "MQTT_BROKER_URI is required." 1>&2; exit 1; fi
if [[ ! "${STUN_URL}" ]]; then echo "STUN_URL is required." 1>&2; exit 1; fi
if [[ ! "${TURN_PASSWORD}" ]]; then echo "TURN_PASSWORD is required." 1>&2; exit 1; fi
if [[ ! "${TURN_URL}" ]]; then echo "TURN_URL is required." 1>&2; exit 1; fi
if [[ ! "${TURN_USERNAME}" ]]; then echo "TURN_USERNAME is required." 1>&2; exit 1; fi

N_AGENTS="${1}"
CONFERENCE_ROOM_ID="${2}"
SLEEP_SECONDS="${3:-1}"

if [[ ! "${N_AGENTS}" ]]; then echo "N_AGENTS is required." 1>&2; exit 1; fi
if [[ ! "${CONFERENCE_ROOM_ID}" ]]; then echo "CONFERENCE_ROOM_ID is required." 1>&2; exit 1; fi

# Create label prefix string based on machine hostname
HOST_ID=$(hostname | sha256sum)
LABEL_PREFIX=${HOST_ID:0:8}

for (( i=0; i<N_AGENTS; i++ ))
do
wrtc-agent \
-c wrtc-$i.${users[index]} \
-e ${CONFERENCE_API_ENDPOINT} \
-n ${CONFERENCE_APP_NAME} \
-P ${tokens[index]} \
-r ${CONFERENCE_ROOM_ID} \
--stun ${STUN_URL} \
--turn ${TURN_URL} \
--turn-username ${TURN_USERNAME} \
--turn-password ${TURN_PASSWORD} \
-u ${BROKER_URI} \
--vc ${VIDEO_CODEC} &
-c "${LABEL_PREFIX}-${i}.${ACCOUNT_ID}" \
-e "${CONFERENCE_API_ENDPOINT}" \
-n "${CONFERENCE_APP_NAME}" \
-P "${ACCESS_TOKEN}" \
-r "${CONFERENCE_ROOM_ID}" \
--stun "${STUN_URL}" \
--turn "${TURN_URL}" \
--turn-username "${TURN_USERNAME}" \
--turn-password "${TURN_PASSWORD}" \
-u "${MQTT_BROKER_URI}" &

echo $!

sleep $SLEEP_SECONDS
sleep "$SLEEP_SECONDS"
done

wait
21 changes: 0 additions & 21 deletions scripts/tokens.sh

This file was deleted.

0 comments on commit 89c627e

Please sign in to comment.