-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
privileged_tests.go
48 lines (38 loc) · 1.22 KB
/
privileged_tests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package RuntimeTest
import (
"context"
"fmt"
"path/filepath"
"time"
. "github.com/onsi/gomega"
. "github.com/cilium/cilium/test/ginkgo-ext"
"github.com/cilium/cilium/test/helpers"
)
const (
// The privileged unit tests can take more than 4 minutes, the default
// timeout for helper commands.
privilegedUnitTestTimeout = 30 * time.Minute
)
var _ = Describe("RuntimePrivilegedUnitTests", func() {
var vm *helpers.SSHMeta
BeforeAll(func() {
vm = helpers.InitRuntimeHelper(helpers.Runtime, logger)
res := vm.ExecWithSudo("systemctl stop cilium")
res.ExpectSuccess("Failed trying to stop cilium via systemctl")
ExpectCiliumNotRunning(vm)
})
AfterAll(func() {
err := vm.RestartCilium()
Expect(err).Should(BeNil(), "Failed to restart Cilium")
vm.CloseSSHClient()
})
It("Run Tests", func() {
path, _ := filepath.Split(vm.BasePath())
ctx, cancel := context.WithTimeout(context.Background(), privilegedUnitTestTimeout)
defer cancel()
res := vm.ExecContext(ctx, fmt.Sprintf("bash -c 'sudo make -C %s tests-privileged | ts \"[%%H:%%M:%%S]\"; exit \"${PIPESTATUS[0]}\"'", path))
res.ExpectSuccess("Failed to run privileged unit tests")
})
})