-
Notifications
You must be signed in to change notification settings - Fork 3k
/
chaos_agent.go
52 lines (38 loc) · 1.41 KB
/
chaos_agent.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
49
50
51
52
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package RuntimeTest
import (
"fmt"
. "github.com/onsi/gomega"
. "github.com/cilium/cilium/test/ginkgo-ext"
"github.com/cilium/cilium/test/helpers"
)
var agentChaosTests = func() {
var vm *helpers.SSHMeta
BeforeAll(func() {
vm = helpers.InitRuntimeHelper(helpers.Runtime, logger)
})
AfterAll(func() {
vm.CloseSSHClient()
})
It("removing leftover Cilium interfaces", func() {
originalLinks, err := vm.Exec("sudo ip link show | wc -l").IntOutput()
Expect(err).Should(BeNil())
_ = vm.Exec("sudo ip link add lxc12345 type veth peer name tmp54321")
err = vm.RestartCilium()
Expect(err).Should(BeNil(), "restarting Cilium failed")
status := vm.Exec("sudo ip link show lxc12345")
status.ExpectFail("leftover interface were not properly cleaned up")
links, err := vm.Exec("sudo ip link show | wc -l").IntOutput()
Expect(err).Should(BeNil(), "Cannot get link layer information")
Expect(links).Should(Equal(originalLinks),
"Some network interfaces were accidentally removed!")
}, 300)
It("Checking for file-descriptor leak", func() {
threshold := 5000
fds, err := vm.Exec("sudo lsof -p `pidof cilium-agent` -p `pidof cilium-docker` 2>/dev/null | wc -l").IntOutput()
Expect(err).Should(BeNil())
Expect(fds).To(BeNumerically("<", threshold),
fmt.Sprintf("%d file descriptors open from Cilium processes", fds))
}, 300)
}