1
1
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
# SPDX-License-Identifier: Apache-2.0
3
3
"""Tests that verify the jailer's behavior."""
4
+
5
+ # pylint: disable=redefined-outer-name
6
+
4
7
import functools
5
8
import http .client as http_client
6
9
import os
@@ -139,11 +142,11 @@ def test_exec_file_not_exist(test_microvm_with_api, tmp_path):
139
142
test_microvm .spawn ()
140
143
141
144
142
- def test_default_chroot_hierarchy (test_microvm_with_initrd ):
145
+ def test_default_chroot_hierarchy (test_microvm_with_api ):
143
146
"""
144
147
Test the folder hierarchy created by default by the jailer.
145
148
"""
146
- test_microvm = test_microvm_with_initrd
149
+ test_microvm = test_microvm_with_api
147
150
148
151
test_microvm .spawn ()
149
152
@@ -190,11 +193,11 @@ def test_default_chroot_hierarchy(test_microvm_with_initrd):
190
193
)
191
194
192
195
193
- def test_arbitrary_usocket_location (test_microvm_with_initrd ):
196
+ def test_arbitrary_usocket_location (test_microvm_with_api ):
194
197
"""
195
198
Test arbitrary location scenario for the api socket.
196
199
"""
197
- test_microvm = test_microvm_with_initrd
200
+ test_microvm = test_microvm_with_api
198
201
test_microvm .jailer .extra_args = {"api-sock" : "api.socket" }
199
202
200
203
test_microvm .spawn ()
@@ -352,12 +355,11 @@ def check_limits(pid, no_file, fsize):
352
355
assert hard == fsize
353
356
354
357
355
- def test_cgroups (test_microvm_with_initrd , sys_setup_cgroups ):
358
+ def test_cgroups (test_microvm_with_api , sys_setup_cgroups ):
356
359
"""
357
360
Test the cgroups are correctly set by the jailer.
358
361
"""
359
- # pylint: disable=redefined-outer-name
360
- test_microvm = test_microvm_with_initrd
362
+ test_microvm = test_microvm_with_api
361
363
test_microvm .jailer .cgroup_ver = sys_setup_cgroups
362
364
if test_microvm .jailer .cgroup_ver == 2 :
363
365
test_microvm .jailer .cgroups = ["cpu.weight.nice=10" ]
@@ -389,12 +391,11 @@ def test_cgroups(test_microvm_with_initrd, sys_setup_cgroups):
389
391
)
390
392
391
393
392
- def test_cgroups_custom_parent (test_microvm_with_initrd , sys_setup_cgroups ):
394
+ def test_cgroups_custom_parent (test_microvm_with_api , sys_setup_cgroups ):
393
395
"""
394
396
Test cgroups when a custom parent cgroup is used.
395
397
"""
396
- # pylint: disable=redefined-outer-name
397
- test_microvm = test_microvm_with_initrd
398
+ test_microvm = test_microvm_with_api
398
399
test_microvm .jailer .cgroup_ver = sys_setup_cgroups
399
400
test_microvm .jailer .parent_cgroup = "custom_cgroup/group2"
400
401
if test_microvm .jailer .cgroup_ver == 2 :
@@ -432,12 +433,11 @@ def test_cgroups_custom_parent(test_microvm_with_initrd, sys_setup_cgroups):
432
433
)
433
434
434
435
435
- def test_node_cgroups (test_microvm_with_initrd , sys_setup_cgroups ):
436
+ def test_node_cgroups (test_microvm_with_api , sys_setup_cgroups ):
436
437
"""
437
438
Test the numa node cgroups are correctly set by the jailer.
438
439
"""
439
- # pylint: disable=redefined-outer-name
440
- test_microvm = test_microvm_with_initrd
440
+ test_microvm = test_microvm_with_api
441
441
test_microvm .jailer .cgroup_ver = sys_setup_cgroups
442
442
443
443
# Retrieve CPUs from NUMA node 0.
@@ -462,12 +462,11 @@ def test_node_cgroups(test_microvm_with_initrd, sys_setup_cgroups):
462
462
)
463
463
464
464
465
- def test_cgroups_without_numa (test_microvm_with_initrd , sys_setup_cgroups ):
465
+ def test_cgroups_without_numa (test_microvm_with_api , sys_setup_cgroups ):
466
466
"""
467
467
Test the cgroups are correctly set by the jailer, without numa assignment.
468
468
"""
469
- # pylint: disable=redefined-outer-name
470
- test_microvm = test_microvm_with_initrd
469
+ test_microvm = test_microvm_with_api
471
470
test_microvm .jailer .cgroup_ver = sys_setup_cgroups
472
471
if test_microvm .jailer .cgroup_ver == 2 :
473
472
test_microvm .jailer .cgroups = ["cpu.weight=2" ]
@@ -494,12 +493,11 @@ def test_cgroups_without_numa(test_microvm_with_initrd, sys_setup_cgroups):
494
493
cgroup_v2_available () is True , reason = "Requires system with cgroup-v1 enabled."
495
494
)
496
495
@pytest .mark .usefixtures ("sys_setup_cgroups" )
497
- def test_v1_default_cgroups (test_microvm_with_initrd ):
496
+ def test_v1_default_cgroups (test_microvm_with_api ):
498
497
"""
499
498
Test if the jailer is using cgroup-v1 by default.
500
499
"""
501
- # pylint: disable=redefined-outer-name
502
- test_microvm = test_microvm_with_initrd
500
+ test_microvm = test_microvm_with_api
503
501
test_microvm .jailer .cgroups = ["cpu.shares=2" ]
504
502
505
503
test_microvm .spawn ()
@@ -513,11 +511,11 @@ def test_v1_default_cgroups(test_microvm_with_initrd):
513
511
)
514
512
515
513
516
- def test_args_default_resource_limits (test_microvm_with_initrd ):
514
+ def test_args_default_resource_limits (test_microvm_with_api ):
517
515
"""
518
516
Test the default resource limits are correctly set by the jailer.
519
517
"""
520
- test_microvm = test_microvm_with_initrd
518
+ test_microvm = test_microvm_with_api
521
519
522
520
test_microvm .spawn ()
523
521
@@ -538,11 +536,11 @@ def test_args_default_resource_limits(test_microvm_with_initrd):
538
536
assert hard == - 1
539
537
540
538
541
- def test_args_resource_limits (test_microvm_with_initrd ):
539
+ def test_args_resource_limits (test_microvm_with_api ):
542
540
"""
543
541
Test the resource limits are correctly set by the jailer.
544
542
"""
545
- test_microvm = test_microvm_with_initrd
543
+ test_microvm = test_microvm_with_api
546
544
test_microvm .jailer .resource_limits = RESOURCE_LIMITS
547
545
548
546
test_microvm .spawn ()
0 commit comments