gpu-mode / discord-cluster-manager

Hook up GPUs to your Discord channel and start running jobs via DMs!
5 stars 3 forks source link

Add smoke test for discord-bot.py #24

Closed b9r5 closed 6 days ago

b9r5 commented 1 week ago

Adds a smoke test script that checks message thread contents for happy path messages.

Tested with this thread on my Discord server:

python3 tests/discord-bot-smoke-test.py \ 
  https://discord.com/channels/1304323138586411018/1304323139093794868/1307454882684342323

and this job: https://github.com/gpu-mode/discord-cluster-manager/actions/runs/11873319052

$ python3 tests/discord-bot-smoke-test.py https://discord.com/channels/1304323138586411018/1304323139093794868/1307454882684342323
2024-11-16 13:22:38 - INFO - Running smoke tests...
2024-11-16 13:22:38 INFO     discord.client logging in using static token
2024-11-16 13:22:38 - INFO - logging in using static token
2024-11-16 13:22:39 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 526a0979df66540fcfed9900f98938d5).
2024-11-16 13:22:39 - INFO - Shard ID None has connected to Gateway (Session ID: 526a0979df66540fcfed9900f98938d5).
2024-11-16 13:22:42 - INFO - Found thread: Training Job - 2024-11-16 13:18.
2024-11-16 13:22:42 - INFO - All required strings were found in the thread.
2024-11-16 13:22:42 - INFO - All tests passed!

And when tested on a thread that does not have all required strings:

$ python3 tests/discord-bot-smoke-test.py https://discord.com/channels/1304323138586411018/1304323139093794868/1307431944581287936
2024-11-16 13:53:18 - INFO - Running smoke tests...
2024-11-16 13:53:18 INFO     discord.client logging in using static token
2024-11-16 13:53:18 - INFO - logging in using static token
2024-11-16 13:53:19 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 731d35c6a05672491bf14021b9e1c641).
2024-11-16 13:53:19 - INFO - Shard ID None has connected to Gateway (Session ID: 731d35c6a05672491bf14021b9e1c641).
2024-11-16 13:53:21 - INFO - Found thread: asdf.
2024-11-16 13:53:22 - WARNING - Some required string was not found in the thread!
2024-11-16 13:53:22 - INFO - Thread contents were: 
2024-11-16 13:53:22 - INFO -    zxcv

2024-11-16 13:53:22 - WARNING - One or more tests failed!
b9r5 commented 1 week ago

I modified the smoke test script to send a smoke test message and listen for responses. This saves the user the trouble of having to find a message link for input to the smoke test script. I also made the script suitable for use in a PR flow.