mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-08 08:10:30 +00:00
test(e2e): speed up and cover exec and Kubernetes modes (#1363)
Follow-up to https://gitea.com/gitea/runner/pulls/1362, whose crash e2e missed because it only drove the daemon on Docker. - `dispatch`, `failure_paths` and `reusable_workflow` run through the daemon and `exec`, each on Docker and one shared k3s cluster. - Fixed sleeps become gates the test releases, the job timeout uses a 15s runner deadline, k3s boots alongside Gitea, Gitea's data is on tmpfs. - Outside a container, `make test-e2e` runs `go test` in a Linux container on its own network like CI, so local runs take the same paths. Local wall time: | | Before | After | |---|---|---| | Suite | 84s | 27–35s | | `job_timeout` | 64s | 17s | | `reconnect` | 22s | 4.5s | | `capacity/serial` | 20s | 2s | | `cli_shutdown_drains` | 14s | 2.3s | | `kubernetes` | 31s | 21–23s | _Written by Claude (Opus 5.5)._ --------- Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1363 Reviewed-by: bircni <[email protected]> Co-authored-by: silverwind <[email protected]>
This commit is contained in:
1 parent
2e72cf902a
commit
a46d3f3eda
23 files changed
+577
-340
No files matched your search
+15
-4
@@ -10,6 +10,8 @@ import (
|
||||
"io"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
@@ -101,6 +103,10 @@ func (p *flakyProxy) restore() { p.down.Store(false) }
|
||||
func testReconnect(t *testing.T) {
|
||||
t.Parallel()
|
||||
api, repo := newScenario(t)
|
||||
gate, release := newGate(t)
|
||||
if err := api.CreateVariable(t.Context(), repo, "E2E_GATE", gate); err != nil {
|
||||
t.Fatalf("create gate variable: %v", err)
|
||||
}
|
||||
proxy := newFlakyProxy(t, fixture.baseURL)
|
||||
startRunner(t, repo, "e2e-reconnect", runnerOptions{host: true, address: proxy.URL()})
|
||||
|
||||
@@ -112,14 +118,19 @@ func testReconnect(t *testing.T) {
|
||||
|
||||
pushWorkflow(t, api, repo, "reconnect.yml")
|
||||
slow := waitForRunAfter(t, api, repo, idle.ID)
|
||||
waitForRunningJobLog(t, api, repo, slow.ID, "e2e-before-outage")
|
||||
// the job logs a line per second, so a long outage spans several that can only arrive after it
|
||||
waitForRunningJobLog(t, api, repo, slow.ID, "e2e-before-outage", 1)
|
||||
// the job logs a line every 200ms until released, so the outage spans several that can only arrive after it
|
||||
proxy.cut(t, 8)
|
||||
proxy.restore()
|
||||
release()
|
||||
requireSuccess(t, api, repo, slow.ID)
|
||||
logs := runLogs(t, api, repo, slow.ID)
|
||||
for i := 1; i <= 15; i++ {
|
||||
if tick := fmt.Sprintf("tick-%02d", i); commandRow(logs, tick) != tick {
|
||||
ticks, err := strconv.Atoi(strings.TrimPrefix(commandRow(logs, "ticks="), "ticks="))
|
||||
if err != nil {
|
||||
t.Fatalf("the job did not report its tick count: %v\n%s", err, logs)
|
||||
}
|
||||
for i := 1; i <= ticks; i++ {
|
||||
if tick := fmt.Sprintf("tick-%d", i); commandRow(logs, tick) != tick {
|
||||
t.Errorf("log line %s written during or after the outage was lost:\n%s", tick, logs)
|
||||
break
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user