Keep similar-ai from tripping the global circuit on a lone URL 502, clamp Qdrant search to 100, and add Server-Timing plus slow-request logging. Studio shared props, Academy S3 exists caching, heat chunking, and Redis/scheduler hygiene stay in this rollout.
74 lines
2.4 KiB
PHP
74 lines
2.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Jobs;
|
|
|
|
use App\Jobs\RecComputeSimilarByBehaviorJob;
|
|
use App\Jobs\RecComputeSimilarByTagsJob;
|
|
use App\Jobs\RecComputeSimilarHybridJob;
|
|
use ReflectionClass;
|
|
use Tests\TestCase;
|
|
|
|
final class RecComputeSerializedCompatibilityTest extends TestCase
|
|
{
|
|
public function test_old_serialized_tags_job_without_after_artwork_id_can_run(): void
|
|
{
|
|
$job = $this->unserializeWithoutAfterArtworkId(new RecComputeSimilarByTagsJob(null, 200, 99));
|
|
|
|
$this->assertNull($job->cursorAfterArtworkId());
|
|
}
|
|
|
|
public function test_old_serialized_behavior_job_without_after_artwork_id_can_run(): void
|
|
{
|
|
$job = $this->unserializeWithoutAfterArtworkId(new RecComputeSimilarByBehaviorJob(null, 200, 42));
|
|
|
|
$this->assertNull($job->cursorAfterArtworkId());
|
|
}
|
|
|
|
public function test_old_serialized_hybrid_job_without_after_artwork_id_can_run(): void
|
|
{
|
|
$job = $this->unserializeWithoutAfterArtworkId(new RecComputeSimilarHybridJob(null, 200, 7));
|
|
|
|
$this->assertNull($job->cursorAfterArtworkId());
|
|
}
|
|
|
|
public function test_new_cursor_jobs_keep_after_artwork_id(): void
|
|
{
|
|
$job = unserialize(serialize(new RecComputeSimilarByBehaviorJob(null, 200, 15)));
|
|
|
|
$this->assertSame(15, $job->cursorAfterArtworkId());
|
|
}
|
|
|
|
public function test_laravel_serialize_roundtrip_keeps_queueable_and_cursor_fields(): void
|
|
{
|
|
$original = new RecComputeSimilarByTagsJob(5, 50, 11);
|
|
$original->onQueue('default');
|
|
|
|
$copy = unserialize(serialize($original));
|
|
|
|
$this->assertInstanceOf(RecComputeSimilarByTagsJob::class, $copy);
|
|
$this->assertSame(11, $copy->cursorAfterArtworkId());
|
|
$this->assertSame('default', $copy->queue);
|
|
$this->assertSame(600, $copy->timeout);
|
|
$this->assertSame(2, $copy->tries);
|
|
}
|
|
|
|
/**
|
|
* @template T of RecComputeSimilarByTagsJob|RecComputeSimilarByBehaviorJob|RecComputeSimilarHybridJob
|
|
* @param T $job
|
|
* @return T
|
|
*/
|
|
private function unserializeWithoutAfterArtworkId(object $job): object
|
|
{
|
|
$values = $job->__serialize();
|
|
$class = $job::class;
|
|
unset($values["\0{$class}\0afterArtworkId"]);
|
|
|
|
$restored = (new ReflectionClass($class))->newInstanceWithoutConstructor();
|
|
$restored->__unserialize($values);
|
|
|
|
return $restored;
|
|
}
|
|
}
|