Skip to content

Commit ef3dd29

Browse files
committed
fix: test_cross_mountpoints skips ownership events when users match
1 parent 3416f9f commit ef3dd29

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

tests/test_path_rename.py

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -451,28 +451,39 @@ def test_cross_mountpoints(
451451
container_id=test_container.id[:12],
452452
)
453453

454-
server.wait_events(
455-
[
456-
Event(
457-
process=touch,
458-
event_type=EventType.OPEN,
459-
file=mounted_file,
460-
host_path=host_path,
461-
),
462-
Event(
463-
process=first_rename,
464-
event_type=EventType.CREATION,
465-
file=ovfs_file,
466-
host_path='',
467-
),
454+
events = [
455+
Event(
456+
process=touch,
457+
event_type=EventType.OPEN,
458+
file=mounted_file,
459+
host_path=host_path,
460+
),
461+
Event(
462+
process=first_rename,
463+
event_type=EventType.CREATION,
464+
file=ovfs_file,
465+
host_path='',
466+
),
467+
]
468+
469+
# If the id for the current process and the process in the container (root)
470+
# match, the ownership events are skipped
471+
curr_id = (os.getuid(), os.getgid())
472+
root_id = (0, 0)
473+
if curr_id != root_id:
474+
events.append(
468475
Event(
469476
process=first_rename,
470477
event_type=EventType.OWNERSHIP,
471478
file=ovfs_file,
472479
host_path='',
473480
owner_uid=owner_uid,
474481
owner_gid=owner_gid,
475-
),
482+
)
483+
)
484+
485+
events.extend(
486+
[
476487
Event(
477488
process=first_rename,
478489
event_type=EventType.PERMISSION,
@@ -492,14 +503,23 @@ def test_cross_mountpoints(
492503
file=mounted_file,
493504
host_path=host_path,
494505
),
506+
]
507+
)
508+
509+
if curr_id != root_id:
510+
events.append(
495511
Event(
496512
process=second_rename,
497513
event_type=EventType.OWNERSHIP,
498514
file=mounted_file,
499515
host_path=host_path,
500516
owner_uid=owner_uid,
501517
owner_gid=owner_gid,
502-
),
518+
)
519+
)
520+
521+
events.extend(
522+
[
503523
Event(
504524
process=second_rename,
505525
event_type=EventType.PERMISSION,
@@ -513,5 +533,7 @@ def test_cross_mountpoints(
513533
file=ovfs_file,
514534
host_path='',
515535
),
516-
],
536+
]
517537
)
538+
539+
server.wait_events(events)

0 commit comments

Comments
 (0)