-
Notifications
You must be signed in to change notification settings - Fork 0
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
#58 Made the pytest-slc plugin using the pyexasol_connection #59
Changes from 3 commits
d72ddc2
a68a312
4854404
f442c8c
fee95ac
6c8238e
a3ec49a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# 0.3.0 - 2024-09-20 | ||
# 0.3.0 - 2024-09-23 | ||
|
||
## Summary | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
from __future__ import annotations | ||
from pathlib import Path | ||
import getpass | ||
from exasol.pytest_backend import paralleltask | ||
import pytest | ||
|
||
import exasol.bucketfs as bfs | ||
from exasol.python_extension_common.deployment.language_container_deployer import LanguageContainerDeployer | ||
from exasol.python_extension_common.deployment.language_container_deployer import ( | ||
LanguageContainerDeployer, LanguageActivationLevel) | ||
from exasol.python_extension_common.deployment.language_container_builder import LanguageContainerBuilder | ||
|
||
BFS_CONTAINER_DIRECTORY = 'container' | ||
|
@@ -62,19 +64,49 @@ def export_slc(slc_builder, export_slc_async) -> Path | None: | |
return Path(export_info.cache_file) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def language_alias(project_short_tag): | ||
""" | ||
The user can override this fixture if they want to provide a more meaningful | ||
name for the language alias. | ||
""" | ||
owner = getpass.getuser() | ||
return f"PYTHON3-{project_short_tag or 'EXTENSION'}-{owner}" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def upload_slc(slc_builder, export_slc, | ||
def deploy_slc(slc_builder, export_slc, | ||
pyexasol_connection, backend_aware_bucketfs_params): | ||
""" | ||
The fixture provides a function uploading the language container to a database, | ||
according to the selected backends. | ||
The fixture provides a function deploying the language container in a database. | ||
The function can be called multiple times, allowing to activate the container with | ||
multiple aliases. However, the container will be uploaded only once. | ||
""" | ||
bucket_file_path = '' | ||
|
||
def func(language_alias: str) -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess, you changed it to that, such that we can isolate the aliases per test, if it necessary. I could assume, in case of the deployer tests and the extension tests that could be necessary. Or, did you think of a different reason. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the motivation is described in the related ticket #58:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But I have some more questions:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My question was related to the function and not the Pyexasol connection There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We used to take the language_alias from the LanguageContainerBuilder. As we found, the language_alias is not actually required to build a language container; it is only for testing it, which we don't do. So it was removed from the LanguageContainerBuilder. But we do need it for the container deployer. Hence is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But good point , maybe we need a fixture that returns a function that activates the SLC for a connection There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah - very good, thank you! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Decision:
|
||
nonlocal bucket_file_path | ||
if (slc_builder is not None) and (export_slc is not None): | ||
bucketfs_path = bfs.path.build_path(**backend_aware_bucketfs_params, | ||
path=BFS_CONTAINER_DIRECTORY) | ||
deployer = LanguageContainerDeployer(pyexasol_connection=pyexasol_connection, | ||
bucketfs_path=bucketfs_path, | ||
language_alias=language_alias) | ||
deployer.run(container_file=export_slc, alter_system=True, allow_override=True) | ||
if bucket_file_path: | ||
# The container has already been uploaded and just needs to be activated | ||
for alter_type in [LanguageActivationLevel.Session, LanguageActivationLevel.System]: | ||
deployer.activate_container(bucket_file_path, alter_type, allow_override=True) | ||
else: | ||
bucket_file_path = export_slc.name | ||
deployer.run(container_file=export_slc, bucket_file_path=bucket_file_path, | ||
alter_system=True, allow_override=True) | ||
return func | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def deployed_slc(deploy_slc, language_alias) -> None: | ||
""" | ||
The fixture calls deploy_slc() once, with the language_alis defined in the fixture | ||
with the corresponded name. | ||
""" | ||
deploy_slc(language_alias) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.