Skip to content

FUSE SUPPORT #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 19, 2025
Merged

FUSE SUPPORT #184

merged 5 commits into from
Mar 19, 2025

Conversation

dura0ok
Copy link
Collaborator

@dura0ok dura0ok commented Feb 20, 2025

No description provided.

@dura0ok dura0ok changed the title add change data dir option FUSE SUPPORT Feb 20, 2025
@dura0ok dura0ok force-pushed the fuse-helpers branch 2 times, most recently from ca2bf88 to 032f142 Compare February 20, 2025 12:34
testgres/node.py Outdated
@@ -316,7 +316,14 @@ def logs_dir(self):
@property
def data_dir(self):
# NOTE: we can't run initdb without user's args
return os.path.join(self.base_dir, DATA_DIR)
if hasattr(self, '_data_dir'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

как-то путанно выходит, может через DATA_DIR, только проверять абсолютный или относительный путь там указан? Есть абсолютный, то не подставлять base_dir

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не, я создаю просто пустую директорию куда буду монтировать fuse и хочу потом сменить data_dir у ноды на нее, чтобы можно было ноду запустить с новой директорией.
У директория куда монтируется не обязательно называется data.
Какая разница.

Copy link
Collaborator

@dmitry-lipetsk dmitry-lipetsk Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Привет.

Я с подозрением отношусь к этой фиче со сменой директории у ноды. Ноду нужно сразу создать с указанием нужной директории и после этого не давать её менять. То, что это (как я понимаю) сейчас невозможно - это другой вопрос.

У нас есть base_dir. От неё мы "наследуем" data_dir и log_dir.

Нужно иметь возможность явно указать эти data_dir и base_dir. Это будет уже совсем другой тип ноды, у которой нет base_dir.

По хорошему тут нужен другой вариант, который, в упрощенной форме, выглядит так:

  • Нужно соорудить базовый класс для PostgresNode - PostgresNodeBase.
  • У PostgresNodeBase будет два "абстрактных" свойства - data_dir и log_dir.
  • Туда же, в PostgresNodeBase, перенесем функционал PostgresNode.
  • Текущий PostgresNode наследует этот PostgresNodeBase и завязывает data_dir и log_dir на base_dir
  • Вариант ноды, в которой можно указывать data_dir и log_dir делаем другим классом. Скажем - PostgresNode2. В его конструктор будут передаваться явные значения для data_dir и log_dir.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как идея может просто тогда давать возможность задавать DataDir при конструкции ноды?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно, но тогда нужно custom_data_dir задавать, чтобы не конфликтовало с def data_dir(self). а вот в data_dir определять в зависимости от того задан custom_data_dir или нет.

Copy link
Collaborator Author

@dura0ok dura0ok Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demonolock @dmitry-lipetsk
Подумал и переделал это в корне по другому. Теперь можно указать при старте ноды и ее остановке custom_data_dir.
Так ок?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demonolock @dmitry-lipetsk убрал сеттер вовсе, обошелся без него пустой нодой. Таки сообразил как. Вы правы. Аппрув?

@@ -61,7 +62,7 @@ def __init__(self, test_class: unittest.TestCase,
self.execution_time = None

def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
skip_log_directory=False, expect_error=False, use_backup_dir=True):
skip_log_directory=False, expect_error=False, use_backup_dir=True, daemonize=False):
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это будет раз на команду задаваться или на весь тестовый прогон?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Раз на команду, нужно для того чтобы мочь запустить команду в фоновом режиме. В моем случае чтобы запустить пробэкап с опцией fuse в фоне.

logging.info(f"Process started in background with PID: {self.process.pid}")

if self.process.stdout and self.process.stderr:
stdout_thread = threading.Thread(target=stream_output, args=(self.process.stdout,))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, daemon=True?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, кажется разумно, поправлю.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправлено

stderr=subprocess.STDOUT,
env=env
).decode('utf-8', errors='replace')
if daemonize:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

часть в daemonize можно вынести в функцию например такую form_daemon_process

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сделаю, разумно

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправлено

if daemonize:

def stream_output(stream: subprocess.PIPE) -> None:
for line in iter(stream.readline, ''):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что если в цикле ошибка будет? Кажется нужен try - finally

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Разумно, сделаю

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправлено

testgres/node.py Outdated
@@ -1028,7 +1027,7 @@ def LOCAL__raise_cannot_start_node__std(from_exception):
self.is_started = True
return self

def stop(self, params=[], wait=True):
def stop(self, params=[], wait=True, custom_data_dir=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может быть проблема при внезапной остановке теста. В местах с вызовом stop(), например _try_shutdown. На cleanup еще пожалуйста посмотри, как он должен отработать, обе директории custom_data_dir и data_dir зачищать или только одну?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хм, а как быть? Сохранять custom_data_dir в self и в try shutdown смотреть и убивать?
Вот если бы не в with force, то он просто бы по пиду убивал и все..
cleanup я бы оставил на откуп внешнего пользователя..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как быть - не знаю.

Но выглядит так, как будто код пошел вразнос ))

Copy link
Collaborator

@dmitry-lipetsk dmitry-lipetsk Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю, что все таки надо будет реализовывать ту идею, которую я предложил с самого начала.

Там еще под раздачу попадает os_ops.

В текущем варианте реализована своеобразная логика выбора os_ops для PostgresNode у которой есть проблемы.

@dmitry-lipetsk
Copy link
Collaborator

Насчет data_dir.

Посмотрите #222.

Я пока не добавлял производный класс с поддержкой явных data_dir и logs_dir.

testgres/node.py Outdated
@@ -440,7 +440,6 @@ def logs_dir(self):

@property
def data_dir(self):
# NOTE: we can't run initdb without user's args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Верни пожалуйста комментарий

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

@demonolock demonolock merged commit 81a5eb4 into master Mar 19, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants