festbench-web/tests/Feature/ServerConfigAndSummaryTest.php

96 lines
3.3 KiB
PHP
Raw Normal View History

<?php
use App\Models\BenchmarkRun;
use App\Models\DepthsweepResult;
use App\Models\ServerConfig;
use App\Models\SoftbenchResult;
use App\Models\User;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
test('engine and server config split otherwise identical session bands', function () {
$owner = User::factory()->create();
$first = ServerConfig::create([
'user_id' => $owner->id,
'name' => 'DFlash Q4 draft',
'engine' => 'llama.cpp',
'config_yaml' => '--spec-draft-hf z-lab/Qwen-DFlash:Q4_K_M',
]);
$second = ServerConfig::create([
'user_id' => $owner->id,
'name' => 'No draft',
'engine' => 'llama.cpp',
'config_yaml' => '--no-speculative',
]);
foreach ([$first, $second] as $config) {
$run = BenchmarkRun::factory()->create([
'suite' => 'softbench',
'user_id' => $owner->id,
'label' => 'same test label',
'model_id' => 'same/model',
'model_quant' => 'Q5_K_M',
'gpu' => 'AMD Radeon AI PRO R9700',
'gpu_count' => 1,
'engine' => 'llama.cpp',
'config_id' => $config->id,
]);
SoftbenchResult::factory()->create(['benchmark_run_id' => $run->id]);
}
Artisan::call('festbench:summary');
expect(DB::table('session_summaries')->count())->toBe(2)
->and(DB::table('session_summaries')->pluck('engine')->unique()->all())->toBe(['llama.cpp'])
->and(DB::table('session_summaries')->pluck('config_name')->sort()->values()->all())
->toBe(['DFlash Q4 draft', 'No draft']);
});
test('depthsweep summary expands one run into a row for each thinking level', function () {
$run = BenchmarkRun::factory()->create(['suite' => 'depthsweep', 'visibility' => 'public']);
foreach (['off', 'low', 'medium', 'xhigh'] as $level) {
DepthsweepResult::factory()->count(2)->create([
'benchmark_run_id' => $run->id,
'level' => $level,
'total' => null,
'user_tps' => null,
]);
}
Artisan::call('festbench:summary');
$rows = DB::table('session_suite_rows')->where('suite', 'depthsweep')->orderBy('sequence')->get();
expect($rows)->toHaveCount(4)
->and($rows->pluck('level')->all())->toBe(['off', 'low', 'medium', 'xhigh']);
expect($rows->pluck('avg_user_tps')->filter())->toBeEmpty();
});
test('depthsweep run detail honors a thinking level query filter', function () {
$run = BenchmarkRun::factory()->create(['suite' => 'depthsweep', 'visibility' => 'public']);
DepthsweepResult::factory()->create([
'benchmark_run_id' => $run->id,
'level' => 'off',
'task' => 'off-only-task',
]);
DepthsweepResult::factory()->create([
'benchmark_run_id' => $run->id,
'level' => 'xhigh',
'task' => 'xhigh-only-task',
]);
$this->get(route('runs.show', $run->run_id).'?level=off')
->assertOk()
->assertSee('Thinking level')
->assertSee('off-only-task')
->assertDontSee('xhigh-only-task');
});
test('server configs settings page is available to authenticated users', function () {
$this->actingAs(User::factory()->create())
->get(route('settings.server-configs'))
->assertOk()
->assertSee('Inference Args');
});