@@ -16,6 +16,7 @@ package sgx
16
16
17
17
import (
18
18
"context"
19
+ "fmt"
19
20
"path/filepath"
20
21
"time"
21
22
@@ -28,6 +29,7 @@ import (
28
29
"k8s.io/apimachinery/pkg/labels"
29
30
"k8s.io/kubernetes/test/e2e/framework"
30
31
e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
32
+ e2ejob "k8s.io/kubernetes/test/e2e/framework/job"
31
33
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
32
34
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
33
35
admissionapi "k8s.io/pod-security-admission/api"
@@ -38,6 +40,7 @@ const (
38
40
timeout = time .Second * 120
39
41
kustomizationWebhook = "deployments/sgx_admissionwebhook/overlays/default-with-certmanager/kustomization.yaml"
40
42
kustomizationPlugin = "deployments/sgx_plugin/base/kustomization.yaml"
43
+ stressNGImage = "intel/stress-ng-gramine:devel"
41
44
)
42
45
43
46
func init () {
@@ -80,6 +83,9 @@ func describe() {
80
83
})
81
84
82
85
ginkgo .Context ("When SGX resources are available" , func () {
86
+ var nodeWithEPC string
87
+ var epcCapacity int64
88
+
83
89
ginkgo .BeforeEach (func (ctx context.Context ) {
84
90
ginkgo .By ("checking if the resource is allocatable" )
85
91
if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , "sgx.intel.com/epc" , 150 * time .Second ); err != nil {
@@ -91,6 +97,20 @@ func describe() {
91
97
if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , "sgx.intel.com/provision" , 30 * time .Second ); err != nil {
92
98
framework .Failf ("unable to wait for nodes to have positive allocatable provision resource: %v" , err )
93
99
}
100
+
101
+ nodelist , err := f .ClientSet .CoreV1 ().Nodes ().List (ctx , metav1.ListOptions {})
102
+ if err != nil {
103
+ framework .Failf ("failed to list Nodes: %v" , err )
104
+ }
105
+
106
+ // we have at least one node with sgx.intel.com/epc capacity
107
+ for _ , item := range nodelist .Items {
108
+ if q , ok := item .Status .Allocatable ["sgx.intel.com/epc" ]; ok && q .Value () > 0 {
109
+ epcCapacity = q .Value ()
110
+ nodeWithEPC = item .Name
111
+ break
112
+ }
113
+ }
94
114
})
95
115
96
116
ginkgo .It ("deploys a sgx-sdk-demo pod requesting SGX enclave resources [App:sgx-sdk-demo]" , func (ctx context.Context ) {
@@ -120,6 +140,96 @@ func describe() {
120
140
gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , "testcontainer" ))
121
141
})
122
142
143
+ ginkgo .It ("deploys simultaneous SGX EPC stressor jobs with equal EPC limits but no memory limits [App:sgx-epc-cgroup]" , func (ctx context.Context ) {
144
+ parallelism := int32 (10 ) // TODO: add more
145
+ completions := int32 (10 )
146
+ quantity := resource .NewQuantity (epcCapacity / int64 (parallelism ), resource .BinarySI )
147
+
148
+ testArgs := []string {
149
+ "stress-ng-edmm" ,
150
+ "--vm" ,
151
+ "1" ,
152
+ "--vm-bytes" ,
153
+ fmt .Sprintf ("%db" , epcCapacity / int64 (parallelism )),
154
+ "--page-in" ,
155
+ "-t" ,
156
+ "30" ,
157
+ }
158
+ job := e2ejob .NewTestJobOnNode ("success" , "sgx-epc-stressjob" , v1 .RestartPolicyNever , parallelism , completions , nil , 1 , nodeWithEPC )
159
+
160
+ job .Spec .Template .Spec .Containers [0 ].Image = stressNGImage
161
+ job .Spec .Template .Spec .Containers [0 ].Args = testArgs
162
+ job .Spec .Template .Spec .Containers [0 ].Resources = v1.ResourceRequirements {
163
+ Requests : v1.ResourceList {"sgx.intel.com/epc" : * quantity },
164
+ Limits : v1.ResourceList {"sgx.intel.com/epc" : * quantity },
165
+ }
166
+
167
+ job , err := e2ejob .CreateJob (ctx , f .ClientSet , f .Namespace .Name , job )
168
+ framework .ExpectNoError (err , "failed to create job in namespace: %s" , f .Namespace .Name )
169
+
170
+ err = e2ejob .WaitForJobComplete (ctx , f .ClientSet , f .Namespace .Name , job .Name , completions )
171
+ framework .ExpectNoError (err , "failed to ensure job completion in namespace: %s" , f .Namespace .Name )
172
+ })
173
+
174
+ ginkgo .It ("deploys one SGX EPC stressor job with a known enclave size and no memory limits [App:sgx-epc-cgroup]" , func (ctx context.Context ) {
175
+ quantity := resource .NewQuantity (epcCapacity , resource .BinarySI )
176
+
177
+ testArgs := []string {
178
+ "stress-ng" ,
179
+ "--vm" ,
180
+ "1" ,
181
+ "--vm-bytes" ,
182
+ "128m" ,
183
+ "--page-in" ,
184
+ "-t" ,
185
+ "30" ,
186
+ }
187
+ job := e2ejob .NewTestJobOnNode ("success" , "sgx-epc-stressjob" , v1 .RestartPolicyNever , 1 , 1 , nil , 1 , nodeWithEPC )
188
+
189
+ job .Spec .Template .Spec .Containers [0 ].Image = stressNGImage
190
+ job .Spec .Template .Spec .Containers [0 ].Args = testArgs
191
+ job .Spec .Template .Spec .Containers [0 ].Resources = v1.ResourceRequirements {
192
+ Requests : v1.ResourceList {"sgx.intel.com/epc" : * quantity },
193
+ Limits : v1.ResourceList {"sgx.intel.com/epc" : * quantity },
194
+ }
195
+
196
+ job , err := e2ejob .CreateJob (ctx , f .ClientSet , f .Namespace .Name , job )
197
+ framework .ExpectNoError (err , "failed to create job in namespace: %s" , f .Namespace .Name )
198
+
199
+ err = e2ejob .WaitForJobComplete (ctx , f .ClientSet , f .Namespace .Name , job .Name , 1 )
200
+ framework .ExpectNoError (err , "failed to ensure job completion in namespace: %s" , f .Namespace .Name )
201
+ })
202
+
203
+ ginkgo .It ("deploys one SGX EPC stressor job with dynamic EPC allocation and memory limit set to kill once enough EPC pages are reclaimed [App:sgx-epc-cgroup]" , func (ctx context.Context ) {
204
+ quantity := resource .NewQuantity (epcCapacity / 10 , resource .BinarySI )
205
+
206
+ //TODO: add another job that needs to survive
207
+ testArgs := []string {
208
+ "stress-ng-edmm" ,
209
+ "--bigheap" ,
210
+ "1" ,
211
+ "--bigheap-growth" ,
212
+ "1M" ,
213
+ "--page-in" ,
214
+ "-t" ,
215
+ "60" ,
216
+ }
217
+ job := e2ejob .NewTestJobOnNode ("success" , "sgx-epc-stressjob" , v1 .RestartPolicyNever , 1 , 1 , nil , 1 , nodeWithEPC )
218
+
219
+ job .Spec .Template .Spec .Containers [0 ].Image = stressNGImage
220
+ job .Spec .Template .Spec .Containers [0 ].Args = testArgs
221
+ job .Spec .Template .Spec .Containers [0 ].Resources = v1.ResourceRequirements {
222
+ Requests : v1.ResourceList {"sgx.intel.com/epc" : * quantity },
223
+ Limits : v1.ResourceList {"sgx.intel.com/epc" : * quantity ,
224
+ v1 .ResourceMemory : * quantity },
225
+ }
226
+
227
+ job , err := e2ejob .CreateJob (ctx , f .ClientSet , f .Namespace .Name , job )
228
+ framework .ExpectNoError (err , "failed to create job in namespace: %s" , f .Namespace .Name )
229
+ err = e2ejob .WaitForJobFailed (f .ClientSet , f .Namespace .Name , job .Name )
230
+ framework .ExpectNoError (err , "failed to ensure job completion in namespace: %s" , f .Namespace .Name )
231
+ })
232
+
123
233
ginkgo .When ("there is no app to run [App:noapp]" , func () {
124
234
ginkgo .It ("does nothing" , func () {})
125
235
})
0 commit comments