Switch the project language to English
Comments, doc comments, test names, error and log messages, CLI help, README, Makefile, CI step names and the design document are now all in English. No behaviour changes; the full suite passes under the race detector. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b7417e1a69
commit
28029eb43b
21 files changed
+910
-869
No files matched your search
+39
-42
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// testConfig, testlerin hızlı ve deterministik koşması için hızlandırılmış ayarlar.
|
||||
// testConfig speeds the simulation up so tests stay fast and deterministic.
|
||||
func testConfig() Config {
|
||||
c := Default()
|
||||
c.Tick = time.Millisecond
|
||||
@@ -18,7 +18,7 @@ func testConfig() Config {
|
||||
return c
|
||||
}
|
||||
|
||||
// drain, kanaldaki tüm token'ları toplar ve bitişi bekler.
|
||||
// drain collects every token from the channel and waits for completion.
|
||||
func drain(t *testing.T, ch <-chan Event) (text string, done bool) {
|
||||
t.Helper()
|
||||
var b strings.Builder
|
||||
@@ -35,36 +35,36 @@ func drain(t *testing.T, ch <-chan Event) (text string, done bool) {
|
||||
case EventDone:
|
||||
done = true
|
||||
case EventError:
|
||||
t.Fatalf("beklenmeyen hata: %v", ev.Err)
|
||||
t.Fatalf("unexpected error: %v", ev.Err)
|
||||
}
|
||||
case <-deadline:
|
||||
t.Fatal("zaman aşımı: engine token üretmedi")
|
||||
t.Fatal("timed out waiting for tokens")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineTemelUretim(t *testing.T) {
|
||||
func TestEngineGeneratesTokens(t *testing.T) {
|
||||
e := New(testConfig())
|
||||
defer e.Close()
|
||||
|
||||
ch, err := e.Submit(t.Context(), Prompt{Text: "merhaba dunya", MaxTokens: 10})
|
||||
ch, err := e.Submit(t.Context(), Prompt{Text: "hello world", MaxTokens: 10})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
text, done := drain(t, ch)
|
||||
if !done {
|
||||
t.Error("EventDone gelmedi")
|
||||
t.Error("no EventDone received")
|
||||
}
|
||||
if got := len(strings.Fields(text)); got != 10 {
|
||||
t.Errorf("beklenen 10 token, alınan %d (%q)", got, text)
|
||||
t.Errorf("expected 10 tokens, got %d (%q)", got, text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineIptalBloklariSerbestBirakir(t *testing.T) {
|
||||
// Router'ın iptal propagasyonunu test edebilmesi için kritik davranış:
|
||||
// istemci koptuğunda engine isteği düşürmeli ve KV bloklarını bırakmalı.
|
||||
func TestCancellationReleasesBlocks(t *testing.T) {
|
||||
// Essential for testing the router's cancellation propagation: when the
|
||||
// client goes away the engine must drop the request and free its KV blocks.
|
||||
cfg := testConfig()
|
||||
cfg.DecodeTokensPerSec = 20 // uzun sürsün ki iptal ederken çalışıyor olsun
|
||||
cfg.DecodeTokensPerSec = 20 // slow, so it is still running when cancelled
|
||||
e := New(cfg)
|
||||
defer e.Close()
|
||||
|
||||
@@ -76,7 +76,7 @@ func TestEngineIptalBloklariSerbestBirakir(t *testing.T) {
|
||||
|
||||
waitFor(t, time.Second, func() bool { return e.Stats().Running == 1 })
|
||||
if usage := e.Stats().KVCacheUsage; usage <= 0 {
|
||||
t.Fatal("çalışan istek KV bloğu ayırmadı")
|
||||
t.Fatal("running request reserved no KV blocks")
|
||||
}
|
||||
|
||||
cancel()
|
||||
@@ -86,20 +86,19 @@ func TestEngineIptalBloklariSerbestBirakir(t *testing.T) {
|
||||
return s.Running == 0 && s.KVCacheUsage == 0
|
||||
})
|
||||
|
||||
// Kanal kapanmalı ki istemci tarafı bloke kalmasın.
|
||||
// The channel must close so the client side never blocks.
|
||||
select {
|
||||
case _, open := <-ch:
|
||||
if open {
|
||||
// token kalmış olabilir; kapanana kadar tüket
|
||||
for range ch { //nolint:revive // kanalı boşalt
|
||||
for range ch { //nolint:revive // drain remaining events
|
||||
}
|
||||
}
|
||||
case <-time.After(2 * time.Second):
|
||||
t.Fatal("iptal sonrası kanal kapanmadı")
|
||||
t.Fatal("channel stayed open after cancellation")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineBatchDolunkaKuyrugaAlir(t *testing.T) {
|
||||
func TestRequestsQueueWhenBatchIsFull(t *testing.T) {
|
||||
cfg := testConfig()
|
||||
cfg.MaxNumSeqs = 2
|
||||
cfg.DecodeTokensPerSec = 20
|
||||
@@ -115,56 +114,54 @@ func TestEngineBatchDolunkaKuyrugaAlir(t *testing.T) {
|
||||
waitFor(t, time.Second, func() bool { return e.Stats().Running == 2 })
|
||||
s := e.Stats()
|
||||
if s.Running != 2 {
|
||||
t.Errorf("running %d, MaxNumSeqs=2 aşıldı", s.Running)
|
||||
t.Errorf("running=%d exceeds MaxNumSeqs=2", s.Running)
|
||||
}
|
||||
if s.Waiting != 3 {
|
||||
t.Errorf("waiting %d, beklenen 3", s.Waiting)
|
||||
t.Errorf("waiting=%d, expected 3", s.Waiting)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineKVBlogunaSigmayanIstekReddedilir(t *testing.T) {
|
||||
func TestOversizedRequestIsRejected(t *testing.T) {
|
||||
cfg := testConfig()
|
||||
cfg.NumGPUBlocks = 4
|
||||
cfg.BlockSize = 16 // toplam 64 token kapasite
|
||||
cfg.BlockSize = 16 // 64 tokens of capacity in total
|
||||
e := New(cfg)
|
||||
defer e.Close()
|
||||
|
||||
_, err := e.Submit(t.Context(), Prompt{Text: strings.Repeat("x", 10000), MaxTokens: 100})
|
||||
if err != ErrTooLong {
|
||||
t.Errorf("ErrTooLong beklendi, alınan %v", err)
|
||||
t.Errorf("expected ErrTooLong, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnginePrefixCacheIkinciIstegiHizlandirir(t *testing.T) {
|
||||
func TestPrefixCacheSpeedsUpRepeatedPrompt(t *testing.T) {
|
||||
cfg := testConfig()
|
||||
cfg.PrefillTokensPerSec = 2000 // prefill maliyeti ölçülebilir olsun
|
||||
cfg.PrefillTokensPerSec = 2000 // make prefill cost measurable
|
||||
cfg.DecodeTokensPerSec = 5000
|
||||
e := New(cfg)
|
||||
defer e.Close()
|
||||
|
||||
prompt := Prompt{Text: strings.Repeat("ortak sistem promptu. ", 200), MaxTokens: 5}
|
||||
prompt := Prompt{Text: strings.Repeat("shared system prompt. ", 200), MaxTokens: 5}
|
||||
|
||||
first := timeToFirstToken(t, e, prompt)
|
||||
// İlk istek bitip cache'e yazıldıktan sonra aynısını tekrar gönder.
|
||||
// Send the same prompt again now that the first one populated the cache.
|
||||
second := timeToFirstToken(t, e, prompt)
|
||||
|
||||
if second >= first {
|
||||
t.Errorf("prefix cache TTFT'yi düşürmedi: ilk=%v ikinci=%v", first, second)
|
||||
t.Errorf("prefix cache did not reduce TTFT: first=%v second=%v", first, second)
|
||||
}
|
||||
|
||||
s := e.Stats()
|
||||
if s.PrefixHits == 0 {
|
||||
t.Error("prefix cache hit sayacı artmadı")
|
||||
if e.Stats().PrefixHits == 0 {
|
||||
t.Error("prefix cache hit counter did not advance")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnginePrefixCacheKapaliykenHitYok(t *testing.T) {
|
||||
func TestNoHitsWhenPrefixCacheDisabled(t *testing.T) {
|
||||
cfg := testConfig()
|
||||
cfg.PrefixCacheBlocks = 0
|
||||
e := New(cfg)
|
||||
defer e.Close()
|
||||
|
||||
p := Prompt{Text: strings.Repeat("ayni prompt. ", 50), MaxTokens: 3}
|
||||
p := Prompt{Text: strings.Repeat("same prompt. ", 50), MaxTokens: 3}
|
||||
for range 3 {
|
||||
ch, err := e.Submit(t.Context(), p)
|
||||
if err != nil {
|
||||
@@ -173,11 +170,11 @@ func TestEnginePrefixCacheKapaliykenHitYok(t *testing.T) {
|
||||
drain(t, ch)
|
||||
}
|
||||
if h := e.Stats().PrefixHits; h != 0 {
|
||||
t.Errorf("cache kapalıyken %d hit raporlandı", h)
|
||||
t.Errorf("disabled cache reported %d hits", h)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineKapanisBekleyenleriBosaltir(t *testing.T) {
|
||||
func TestShutdownDrainsPendingRequests(t *testing.T) {
|
||||
cfg := testConfig()
|
||||
cfg.DecodeTokensPerSec = 1
|
||||
e := New(cfg)
|
||||
@@ -197,23 +194,23 @@ func TestEngineKapanisBekleyenleriBosaltir(t *testing.T) {
|
||||
return
|
||||
}
|
||||
case <-deadline:
|
||||
t.Fatal("kapanışta kanal kapanmadı")
|
||||
t.Fatal("channel stayed open after shutdown")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestEngineYapayHata(t *testing.T) {
|
||||
func TestInjectedFailure(t *testing.T) {
|
||||
cfg := testConfig()
|
||||
cfg.FailRate = 1.0
|
||||
e := New(cfg)
|
||||
defer e.Close()
|
||||
|
||||
if _, err := e.Submit(t.Context(), Prompt{Text: "abc"}); err != ErrInjected {
|
||||
t.Errorf("ErrInjected beklendi, alınan %v", err)
|
||||
t.Errorf("expected ErrInjected, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// --- yardımcılar ---
|
||||
// --- helpers ---
|
||||
|
||||
func timeToFirstToken(t *testing.T, e *Engine, p Prompt) time.Duration {
|
||||
t.Helper()
|
||||
@@ -229,7 +226,7 @@ func timeToFirstToken(t *testing.T, e *Engine, p Prompt) time.Duration {
|
||||
}
|
||||
}
|
||||
if ttft == 0 {
|
||||
t.Fatal("hiç token üretilmedi")
|
||||
t.Fatal("no tokens were generated")
|
||||
}
|
||||
return ttft
|
||||
}
|
||||
@@ -243,5 +240,5 @@ func waitFor(t *testing.T, limit time.Duration, cond func() bool) {
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
t.Fatalf("koşul %v içinde sağlanmadı", limit)
|
||||
t.Fatalf("condition not met within %v", limit)
|
||||
}
|
||||
Reference in new issue
Block a user