Skip to content

Commit f45ccc2

Browse files
committed
Upload integration test logs on failure
Signed-off-by: Brad Davidson <[email protected]>
1 parent 0363989 commit f45ccc2

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

.github/workflows/e2e.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ jobs:
9494
run: |
9595
chmod +x ./dist/artifacts/k3s
9696
cd tests/e2e/${{ matrix.etest }}
97-
go test -timeout=45m ./${{ matrix.etest}}_test.go -test.v -ginkgo.v -ci -local
97+
go test -timeout=45m ./${{ matrix.etest }}_test.go -test.v -ginkgo.v -ci -local
9898
- name: On Failure, Upload Journald Logs
9999
uses: actions/upload-artifact@v4
100100
if: ${{ failure() }}
101101
with:
102-
name: e2e-${{ matrix.etest}}-logs
102+
name: e2e-${{ matrix.etest }}-logs
103103
path: tests/e2e/${{ matrix.etest }}/*log.txt
104104
retention-days: 30
105105
- name: On Failure, Launch Debug Session

.github/workflows/integration.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ jobs:
6464
chmod +x ./dist/artifacts/k3s
6565
mkdir -p $GOCOVERDIR
6666
sudo -E env "PATH=$PATH" go test -timeout=45m ./tests/integration/${{ matrix.itest }}/... -run Integration -ginkgo.v -test.v
67+
- name: On Failure, Upload Logs
68+
uses: actions/upload-artifact@v4
69+
if: ${{ failure() }}
70+
with:
71+
name: integration-${{ matrix.itest }}-logs
72+
path: tests/integration/${{ matrix.itest }}/*log.txt
73+
retention-days: 30
6774
- name: On Failure, Launch Debug Session
6875
uses: lhotari/action-upterm@v1
6976
if: ${{ failure() }}

tests/integration/integration.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,13 @@ func K3sStartServer(inputArgs ...string) (*K3sServer, error) {
188188
// Give the server a new group id so we can kill it and its children later
189189
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
190190
// Pipe output to a file for debugging later
191-
f, err := os.Create("./k3log.txt")
191+
f, err := os.Create("./k3s-log.txt")
192192
if err != nil {
193193
return nil, err
194194
}
195+
cmd.Stdout = f
195196
cmd.Stderr = f
196-
logrus.Info("Starting k3s server. Check k3log.txt for logs")
197+
logrus.Infof("Starting k3s server with stdout and stderr written to %s", f.Name())
197198
err = cmd.Start()
198199
return &K3sServer{cmd, f}, err
199200
}
@@ -289,6 +290,7 @@ func K3sSaveLog(server *K3sServer, dump bool) error {
289290
if !dump {
290291
return nil
291292
}
293+
292294
log, err := os.Open(server.log.Name())
293295
if err != nil {
294296
return err

0 commit comments

Comments
 (0)