feat: traefik-selectel-dns — A-записи Selectel по роутам Traefik + CI сборка образа
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package reconciler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/realmanual/traefik-selectel/internal/traefik"
|
||||
)
|
||||
|
||||
func TestRunTicksAndTriggers(t *testing.T) {
|
||||
e := newEnv(nil)
|
||||
e.src.routers = []traefik.Router{router("a", "Host(`app.example.com`)", "enabled")}
|
||||
trigger := make(chan struct{}, 1)
|
||||
var cycles int32
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
e.rec.Run(ctx, time.Hour, 5*time.Millisecond, trigger, func(Result, error) { atomic.AddInt32(&cycles, 1) })
|
||||
close(done)
|
||||
}()
|
||||
waitCycles := func(n int32) {
|
||||
deadline := time.Now().Add(3 * time.Second)
|
||||
for atomic.LoadInt32(&cycles) < n {
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatalf("ожидали %d циклов, было %d", n, atomic.LoadInt32(&cycles))
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
waitCycles(1) // стартовый
|
||||
trigger <- struct{}{}
|
||||
waitCycles(2)
|
||||
cancel()
|
||||
<-done
|
||||
if len(e.dns.created) != 1 {
|
||||
t.Fatalf("created = %v", e.dns.created)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user