Skip to content

Commit 7cb41c7

Browse files
committed
Test user prep adjustments
- Remove setfacl reset - Add more logging which helped troubleshoot hang in CI - Manage coppy-tests .cache dir like .config which may or may not be needed for CI but shouldn't hurt anything to have it there.
1 parent bf7c6bd commit 7cb41c7

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

tasks/test-user-prep.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,51 @@
2424
@click.option('--reinstall', is_flag=True, default=False)
2525
@logs.opts_init
2626
def main(systemd_skip: bool, systemd_force: bool, reinstall: bool):
27+
log.info('Test user prep starting...')
28+
2729
coppy_user = User(username)
2830

2931
if reinstall and coppy_user.exists():
3032
result = utils.sudo_run('pkill', '-u', username, returns=(0, 1))
3133
if result.returncode == 0:
34+
log.info('Waiting on all coppy-tests processes to exit')
3235
# Wait for user's processes to exit or userdel will fail
3336
utils.sub_run('pidwait', '-u', username)
3437
utils.sudo_run('userdel', '-r', username)
3538

3639
# Get rid of cache
3740
coppy_user = User(username)
3841

42+
log.info('Ensuring user exists...')
3943
coppy_user.ensure()
4044
coppy_user_home = coppy_user.home_dir()
4145

4246
if not coppy_user.is_current:
47+
log.info('Adjustments to give current user access to coppy-tests home')
4348
curr_user = User.current()
44-
# This would clear them all (i.e. fix a mistake if you have one)
45-
utils.sub_run('sudo', 'setfacl', '-R', '-b', coppy_user_home)
46-
# utils.sudo_run('setfacl', '-R', '-m', f'u:{curr_user.name}:rwX', coppy_user_home)
47-
# utils.sudo_run('setfacl', '-R', '-d', '-m', f'u:{curr_user.name}:rwX', coppy_user_home)
49+
4850
if coppy_user.name not in curr_user.groups():
4951
log.info(f'Adding your user to the user group: {coppy_user.name}')
5052
utils.sudo_run('usermod', '-aG', coppy_user.name, curr_user.name)
5153
log.warning(
5254
f'Please logout and then back in to enable access to the {coppy_user.name} group.',
5355
)
56+
return
5457
else:
5558
log.info(f'Your user is already in the group: {coppy_user.name}')
5659

5760
# Sticky group so files created by the dev's user can be accessed by coppy-tests user.
5861
utils.sudo_run('chmod', 'g+ws', coppy_user_home)
5962

60-
# Needed for systemd files
6163
config_dpath = coppy_user_home / '.config/'
6264
config_dpath.mkdir(exist_ok=True)
65+
utils.sudo_run('chmod', '-R', 'g+ws', config_dpath)
66+
67+
cache_dpath = coppy_user_home / '.cache/'
68+
cache_dpath.mkdir(exist_ok=True)
69+
utils.sudo_run('chmod', '-R', 'g+ws', cache_dpath)
6370

71+
log.info('Updating sudoers for passwordless access to coppy test user')
6472
sudoers_write('coppy', sudoers.format(coppy_user=username))
6573

6674
# Mise & uv

tests/coppy_tests/libs/os_prep.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def ensure(self):
9595
if self.name in Group.all_names():
9696
group_args = ('-g', self.name)
9797

98+
log.info(f'Creating user: {self.name}')
9899
utils.sudo_run(
99100
'useradd',
100101
'--system',

0 commit comments

Comments
 (0)