#!/usr/bin/env -S v -n -w -cg -gc none -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.core.redisclient import freeflowuniverse.herolib.baobab.runner import time import log // Test script to send RPC calls over Redis to test the runner fn main() { log.info('Starting runner RPC test script') // Connect to Redis mut redis := redisclient.new('127.0.0.1:6379')! // Test runner configuration runner_name := 'test_runner' namespace := '' // Create test jobs test_jobs := [ runner.Job{ id: 'test_job_1' caller_id: 'test_caller' context_id: 'test_context_1' runner: runner_name executor: 'tmux.session1' payload: 'echo "Hello from job 1"' status: .dispatched timeout: 30 created_at: time.now() updated_at: time.now() }, runner.Job{ id: 'test_job_2' caller_id: 'test_caller' context_id: 'test_context_2' runner: runner_name executor: 'tmux.session2.window1' payload: 'ls -la && echo "Job 2 completed"' status: .dispatched timeout: 30 created_at: time.now() updated_at: time.now() }, runner.Job{ id: 'test_job_3' caller_id: 'test_caller' context_id: 'test_context_3' runner: runner_name executor: 'tmux.session3.window1.pane1' payload: 'date && echo "Current time from job 3"' status: .dispatched timeout: 30 created_at: time.now() updated_at: time.now() } ] log.info('Storing ${test_jobs.len} test jobs in Redis and dispatching to runner queue') // Store jobs in Redis and dispatch them to the runner queue for job in test_jobs { // Store job data in Redis job.store_in_redis(mut redis, namespace) or { log.error('Failed to store job ${job.id}: ${err}') continue } // Dispatch job to runner queue by pushing job ID to the queue queue_key := if namespace.len > 0 { "${namespace}:runner:${runner_name}" } else { "runner:${runner_name}" } redis.rpush(queue_key, job.id) or { log.error('Failed to dispatch job ${job.id} to queue ${queue_key}: ${err}') continue } log.info('Dispatched job ${job.id} to queue ${queue_key}') // Small delay between jobs time.sleep(1 * time.second) } log.info('All test jobs dispatched. Monitoring job status...') // Monitor job status for a while for i in 0..30 { // Monitor for 30 seconds log.info('--- Status check ${i + 1} ---') for job in test_jobs { loaded_job := runner.load_from_redis(mut redis, job.id, namespace) or { log.error('Failed to load job ${job.id}: ${err}') continue } log.info('Job ${loaded_job.id}: status=${loaded_job.status}, result="${loaded_job.result}", error="${loaded_job.error}"') } time.sleep(1 * time.second) } log.info('Test completed. Check tmux sessions to see if commands were executed.') log.info('You can run "tmux list-sessions" to see created sessions.') }