-
Notifications
You must be signed in to change notification settings - Fork 451
/
os.go
105 lines (80 loc) · 3.25 KB
/
os.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
Overview
- Tests that there is no segfault in journalctl under load
Test: deploy load to a node
Expected Output
- No segfault in the journalctl logs
**/
package operatingsystem
import (
"context"
"time"
"github.com/onsi/ginkgo/v2"
g "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"github.com/gardener/gardener/test/framework"
"github.com/gardener/gardener/test/framework/resources/templates"
)
var _ = ginkgo.Describe("Operating system testing", func() {
f := framework.NewShootFramework(&framework.ShootConfig{
CreateTestNamespace: true,
})
ginkgo.Context("OperatingSystem load", func() {
const deploymentName = "os-loadtest"
var rootPodExecutor framework.RootPodExecutor
f.Default().Serial().CIt("should not segfault", func(ctx context.Context) {
// choose random node
nodes := &corev1.NodeList{}
err := f.ShootClient.Client().List(ctx, nodes)
framework.ExpectNoError(err)
if len(nodes.Items) == 0 {
ginkgo.Fail("at least one node is needed")
}
err = f.RenderAndDeployTemplate(ctx, f.ShootClient, templates.SimpleLoadDeploymentName, map[string]string{
"name": deploymentName,
"namespace": f.Namespace,
"nodeName": nodes.Items[0].Name,
})
framework.ExpectNoError(err)
err = f.WaitUntilDeploymentIsReady(ctx, deploymentName, f.Namespace, f.ShootClient)
framework.ExpectNoError(err)
ginkgo.By("Wait 10 seconds for the deployment to generate load")
time.Sleep(10 * time.Second)
// deploy root pod on the node with the load
rootPodExecutor = framework.NewRootPodExecutor(f.Logger, f.ShootClient, &nodes.Items[0].Name, f.Namespace)
response, err := rootPodExecutor.Execute(ctx, "journalctl --no-pager")
framework.ExpectNoError(err)
g.Expect(response).ToNot(g.BeNil())
ginkgo.By("Expect no segfault")
journalctlValidation := framework.TextValidation{"segfault": "expect no systemctl segfault"}
err = journalctlValidation.ValidateAsDenylist(response)
framework.ExpectNoError(err)
ginkgo.By("Expect systemctl to respond")
_, err = rootPodExecutor.Execute(ctx, "systemctl")
framework.ExpectNoError(err)
}, 30*time.Minute)
framework.CAfterEach(func(ctx context.Context) {
err := rootPodExecutor.Clean(ctx)
framework.ExpectNoError(err)
deployment := &appsv1.Deployment{}
deployment.Name = deploymentName
deployment.Namespace = f.Namespace
err = framework.DeleteAndWaitForResource(ctx, f.ShootClient, deployment, 5*time.Minute)
framework.ExpectNoError(err)
}, 5*time.Minute)
})
})