From ebcbcf1a7f96f28a6745e66ee7f9fa40e848d952 Mon Sep 17 00:00:00 2001 From: texuf Date: Fri, 9 Aug 2024 00:04:05 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20up=20the=20localhost=20stress=20tests=20s?= =?UTF-8?q?o=20that=20you=20don=E2=80=99t=20have=20to=20cut=20and=20paste?= =?UTF-8?q?=20ids=20(#683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was hard before, now it’s easy. just call ./packages/stress/scripts/localhost_chat_setup.sh ./packages/stress/scripts/localhost_chat.sh ## Summary by CodeRabbit - **New Features** - Enhanced script functionality by sourcing environment variables from a new configuration file for local chat settings. - Introduced persistent storage of environment variables to improve configuration management. - **Chores** - Updated the repository's `.gitignore` to prevent tracking of environment files, improving repository cleanliness and security. - **Improvements** - Improved logging clarity by structuring the output of environment variables in a more readable format. --- .gitignore | 1 + packages/stress/scripts/localhost_chat.sh | 3 +++ ...alhost_setup_chat.sh => localhost_chat_setup.sh} | 0 packages/stress/src/mode/chat/root_chat.ts | 13 ++++++++----- 4 files changed, 12 insertions(+), 5 deletions(-) rename packages/stress/scripts/{localhost_setup_chat.sh => localhost_chat_setup.sh} (100%) diff --git a/.gitignore b/.gitignore index ce1b1328d..61b11b62f 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,4 @@ bin/gen-bindings-remove-struct go.work.sum /packages/stress-testing/.env +/packages/stress/*/.env* diff --git a/packages/stress/scripts/localhost_chat.sh b/packages/stress/scripts/localhost_chat.sh index a830dd76b..4edfb2d14 100755 --- a/packages/stress/scripts/localhost_chat.sh +++ b/packages/stress/scripts/localhost_chat.sh @@ -3,6 +3,9 @@ set -euo pipefail cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" cd .. +# run scripts/localhost_chat_setup.sh to set up the environment variables +source scripts/.env.localhost_chat + echo "stress/scripts/localhost_chat.sh" # diff --git a/packages/stress/scripts/localhost_setup_chat.sh b/packages/stress/scripts/localhost_chat_setup.sh similarity index 100% rename from packages/stress/scripts/localhost_setup_chat.sh rename to packages/stress/scripts/localhost_chat_setup.sh diff --git a/packages/stress/src/mode/chat/root_chat.ts b/packages/stress/src/mode/chat/root_chat.ts index a90a377a0..8eafb6e1d 100644 --- a/packages/stress/src/mode/chat/root_chat.ts +++ b/packages/stress/src/mode/chat/root_chat.ts @@ -1,4 +1,5 @@ import { check, dlogger } from '@river-build/dlog' +import { promises as fs } from 'node:fs' import { isSet } from '../../utils/expect' import { ChatConfig } from './types' import { RiverConfig, makeDefaultChannelStreamId } from '@river-build/sdk' @@ -193,11 +194,13 @@ export async function setupChat(opts: { channelIds.push(await client.createChannel(spaceId, `stress${i}`)) } // log all the deets - logger.log( - `SPACE_ID=${spaceId} ANNOUNCE_CHANNEL_ID=${announceChannelId} CHANNEL_IDS=${channelIds.join( - ',', - )}`, - ) + const envVars = [ + `SPACE_ID=${spaceId}`, + `ANNOUNCE_CHANNEL_ID=${announceChannelId}`, + `CHANNEL_IDS=${channelIds.join(',')}`, + ] + logger.log(envVars.join('\n')) + await fs.writeFile('scripts/.env.localhost_chat', envVars.join('\n')) logger.log('join at', `http://localhost:3000/t/${spaceId}/?invite`) logger.log('or', `http://localhost:3001/spaces/${spaceId}/?invite`) logger.log('done')