Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoucheng361 committed Apr 19, 2024
1 parent 16de09e commit 022b705
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
15 changes: 8 additions & 7 deletions .github/scripts/hypo/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,24 @@ def trash_list(self, user='root'):

@rule(
put_back = st.booleans(),
threads = st.integers(min_value=1, max_value=10),
user=st_sudo_user
)
@precondition(lambda self: self.should_run('restore'))
def restore(self, put_back, user='root'):
result1 = self.cmd1.do_restore(put_back=put_back, user=user)
result2 = self.cmd2.do_restore(put_back=put_back, user=user)
def restore(self, put_back, threads, user='root'):
result1 = self.cmd1.do_restore(put_back=put_back, threads=threads, user=user)
result2 = self.cmd2.do_restore(put_back=put_back, threads=threads, user=user)
assert self.equal(result1, result2), f'\033[31mrestore:\nresult1 is {result1}\nresult2 is {result2}\033[0m'

@rule(
entry = Entries.filter(lambda x: x != multiple()),
thread = st.integers(min_value=1, max_value=10),
threads = st.integers(min_value=1, max_value=10),
user = st_sudo_user
)
@precondition(lambda self: self.should_run('compact'))
def compact(self, entry, thread, user='root'):
result1 = self.cmd1.do_compact(entry=entry, thread=thread, user=user)
result2 = self.cmd2.do_compact(entry=entry, thread=thread, user=user)
def compact(self, entry, threads, user='root'):
result1 = self.cmd1.do_compact(entry=entry, thread=threads, user=user)
result2 = self.cmd2.do_compact(entry=entry, thread=threads, user=user)
assert self.equal(result1, result2), f'\033[31mcompact:\nresult1 is {result1}\nresult2 is {result2}\033[0m'

@rule(
Expand Down
10 changes: 5 additions & 5 deletions .github/scripts/hypo/command_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,12 @@ def do_trash_list(self, user='root'):
self.logger.info(f'do_trash_list succeed')
return tuple(li)

def do_restore(self, index, put_back, user='root'):
def do_restore(self, put_back, threads, user='root'):
abspath = os.path.join(self.mp, '.trash')
try:
li = os.listdir(abspath)
li = os.listdir(abspath)
for trash_dir in li:
cmd = f'sudo -u {user} ./juicefs restore {trash_dir}'
cmd = f'sudo -u {user} ./juicefs restore {trash_dir} --threads {threads}'
if put_back:
cmd += ' --put-back'
self.run_cmd(cmd)
Expand All @@ -323,10 +323,10 @@ def do_trash_restore(self, index, user='root'):
self.logger.info(f'do_trash_restore succeed')
return restored_path

def do_compact(self, entry, thread, user):
def do_compact(self, entry, threads, user):
path = os.path.join(self.root_dir, entry)
try:
self.run_cmd(f'sudo -u {user} ./juicefs compact {path} --thread {thread}')
self.run_cmd(f'sudo -u {user} ./juicefs compact {path} --threads {threads}')
except subprocess.CalledProcessError as e:
return self.handleException(e, 'do_compact', path, user=user)
self.stats.success('do_compact')
Expand Down

0 comments on commit 022b705

Please sign in to comment.