Initial commit: docker compose config
Release Docker multi arch / docker (push) Has been cancelled
Test Install Script / Test Script Syntax (push) Has been cancelled
Test Install Script / Test on almalinux-10 (default) (push) Has been cancelled
Test Install Script / Test on almalinux-10 (root) (push) Has been cancelled
Test Install Script / Test on almalinux-8 (default) (push) Has been cancelled
Test Install Script / Test on almalinux-8 (root) (push) Has been cancelled
Test Install Script / Test on almalinux-9 (default) (push) Has been cancelled
Test Install Script / Test on almalinux-9 (root) (push) Has been cancelled
Test Install Script / Test on amazonlinux-2 (default) (push) Has been cancelled
Test Install Script / Test on amazonlinux-2 (root) (push) Has been cancelled
Test Install Script / Test on debian-11 (default) (push) Has been cancelled
Test Install Script / Test on debian-11 (root) (push) Has been cancelled
Test Install Script / Test on debian-12 (default) (push) Has been cancelled
Test Install Script / Test on debian-12 (root) (push) Has been cancelled
Test Install Script / Test on debian-13 (default) (push) Has been cancelled
Test Install Script / Test on debian-13 (root) (push) Has been cancelled
Test Install Script / Test on fedora-latest (default) (push) Has been cancelled
Test Install Script / Test on fedora-latest (root) (push) Has been cancelled
Test Install Script / Test on rocky-10 (default) (push) Has been cancelled
Test Install Script / Test on rocky-10 (root) (push) Has been cancelled
Test Install Script / Test on rocky-8 (default) (push) Has been cancelled
Test Install Script / Test on rocky-8 (root) (push) Has been cancelled
Test Install Script / Test on rocky-9 (default) (push) Has been cancelled
Test Install Script / Test on rocky-9 (root) (push) Has been cancelled
Test Install Script / Test on ubuntu-22.04 (default) (push) Has been cancelled
Test Install Script / Test on ubuntu-22.04 (root) (push) Has been cancelled
Test Install Script / Test on ubuntu-24.04 (default) (push) Has been cancelled
Test Install Script / Test on ubuntu-24.04 (root) (push) Has been cancelled

This commit is contained in:
2026-05-30 12:07:11 +00:00
commit 616c6b1c62
381 changed files with 55145 additions and 0 deletions
+97
View File
@@ -0,0 +1,97 @@
package rutor
import (
"bytes"
"compress/flate"
"encoding/json"
"os"
"path/filepath"
"strconv"
"sync"
"testing"
"time"
"server/rutor/models"
"server/settings"
)
// TestConcurrentSearchAndLoadDB проверяет отсутствие гонки при одновременном
// обновлении индекса (loadDB) и поиске (Search).
// !Запускать с -count=3
func TestConcurrentSearchAndLoadDB(t *testing.T) {
if settings.BTsets == nil {
settings.BTsets = &settings.BTSets{EnableRutorSearch: true}
defer func() { settings.BTsets = nil }()
} else {
old := settings.BTsets.EnableRutorSearch
settings.BTsets.EnableRutorSearch = true
defer func() { settings.BTsets.EnableRutorSearch = old }()
}
dir := t.TempDir()
oldPath := settings.Path
settings.Path = dir
defer func() { settings.Path = oldPath }()
const numTorrents = 800
seed := make([]*models.TorrentDetails, numTorrents)
for i := 0; i < numTorrents; i++ {
s := strconv.Itoa(i)
seed[i] = &models.TorrentDetails{
Title: "Test Film Number " + s + " Part One Two Three Year",
Name: "Film " + s,
Year: 2015 + i%10,
}
}
data, err := json.Marshal(seed)
if err != nil {
t.Fatal(err)
}
var compressed bytes.Buffer
w, _ := flate.NewWriter(&compressed, flate.DefaultCompression)
_, _ = w.Write(data)
_ = w.Close()
if err := os.WriteFile(filepath.Join(dir, "rutor.ls"), compressed.Bytes(), 0o600); err != nil {
t.Fatal(err)
}
done := make(chan struct{})
var wg sync.WaitGroup
// Горутина: многократно перезагружает БД (долгая перезапись индекса)
wg.Add(1)
go func() {
defer wg.Done()
for i := 0; i < 20; i++ {
select {
case <-done:
return
default:
loadDB()
time.Sleep(5 * time.Millisecond)
}
}
}()
// Несколько горутин: постоянный поиск, пока идёт переиндексация
for i := 0; i < 8; i++ {
wg.Add(1)
go func() {
defer wg.Done()
queries := []string{"Test", "Film", "Number", "Part", "Year", "xxx"}
for j := 0; j < 200; j++ {
select {
case <-done:
return
default:
_ = Search(queries[j%len(queries)])
}
}
}()
}
// Даём время на пересечение loadDB и Search
time.Sleep(800 * time.Millisecond)
close(done)
wg.Wait()
}