Skip to content

Commit

Permalink
Fix up the localhost stress tests so that you don’t have to cut and p…
Browse files Browse the repository at this point in the history
…aste ids (#683)

It was hard before, now it’s easy.


just call 
./packages/stress/scripts/localhost_chat_setup.sh
./packages/stress/scripts/localhost_chat.sh

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## 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.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
texuf authored Aug 9, 2024
1 parent e4f295e commit ebcbcf1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ bin/gen-bindings-remove-struct
go.work.sum

/packages/stress-testing/.env
/packages/stress/*/.env*
3 changes: 3 additions & 0 deletions packages/stress/scripts/localhost_chat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

#
Expand Down
13 changes: 8 additions & 5 deletions packages/stress/src/mode/chat/root_chat.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit ebcbcf1

Please sign in to comment.