1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-01 17:38:36 +00:00

Increase fetch interval for Codeberg

Increase the fetch interval to at least 30 seconds if the runner is
configured to be used with Codeberg. This avoids it being rate limited
when they do actual work and reduces load on Codeberg.
This commit is contained in:
Gusted 2024-01-05 15:07:15 +00:00 committed by Gusted
parent fd0596cd15
commit db2213254d
No known key found for this signature in database
GPG key ID: FD821B732837125F
3 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,37 @@
// Copyright 2024 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package config
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestConfigTune(t *testing.T) {
c := &Config{
Runner: Runner{},
}
t.Run("Public instance tuning", func(t *testing.T) {
c.Runner.FetchInterval = 60 * time.Second
c.Tune("https://codeberg.org")
assert.EqualValues(t, 60*time.Second, c.Runner.FetchInterval)
c.Runner.FetchInterval = 2 * time.Second
c.Tune("https://codeberg.org")
assert.EqualValues(t, 30*time.Second, c.Runner.FetchInterval)
})
t.Run("Non-public instance tuning", func(t *testing.T) {
c.Runner.FetchInterval = 60 * time.Second
c.Tune("https://example.com")
assert.EqualValues(t, 60*time.Second, c.Runner.FetchInterval)
c.Runner.FetchInterval = 2 * time.Second
c.Tune("https://codeberg.com")
assert.EqualValues(t, 2*time.Second, c.Runner.FetchInterval)
})
}