-
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
Conversation
bucketfs_path=bucketfs_path, | ||
language_alias=slc_builder.language_alias) | ||
deployer.run(container_file=export_slc, alter_system=True, allow_override=True) | ||
def func(language_alias: str) -> None: |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the motivation is described in the related ticket #58:
If an extension test uses both
pyexasol_connection
fixture from thepytest-extension
andupload_slc
fixture from thepytest-slc
then the container may not get activated for thepyexasol_connection
session if thepyexasol_connection
fixture is created first. To make sure this doesn't happen thepytest-slc
should depend on thepytest-extension
and use itspyexasol_connection
fixture instead of creating its own connection.
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.
But I have some more questions:
- Could we make the function
func
use thelanguage_alias
that is already known to theslc_builder
? - Why does the fixture return a function instead of just uploading the SLC?
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.
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 comment
The 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 upload_slc
function. We can provide the language_alias
there.
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
We used to take the language_alias from the Builder ... language_alias is not actually required to build a language container ... But for the deployer. ...
Ah - very good, thank you!
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.
Decision:
- Rename fixture upload_slc to deploy_slc
- Add fixture deployed_slc which uses a dummy fixture for alias which needs be overwritten by the extension
- the function returned by deploy_slc fixture uses a state variable stored in deploy_slc fixture to upload the slc only once and only activate it in subsequent calls
bucketfs_path=bucketfs_path, | ||
language_alias=slc_builder.language_alias) | ||
deployer.run(container_file=export_slc, alter_system=True, allow_override=True) | ||
def func(language_alias: str) -> None: |
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.
I guess the motivation is described in the related ticket #58:
If an extension test uses both
pyexasol_connection
fixture from thepytest-extension
andupload_slc
fixture from thepytest-slc
then the container may not get activated for thepyexasol_connection
session if thepyexasol_connection
fixture is created first. To make sure this doesn't happen thepytest-slc
should depend on thepytest-extension
and use itspyexasol_connection
fixture instead of creating its own connection.
@@ -24,7 +24,7 @@ def assert_udf_running(conn: pyexasol.ExaConnection): | |||
with temp_schema(conn) as schema: | |||
udf_name = 'TEST_UDF' | |||
udf_create_sql = ( | |||
f'CREATE OR REPLACE {{LANGUAGE_ALIAS}} SCALAR SCRIPT "{{schema}}"."{{udf_name}}"() ' | |||
f'CREATE OR REPLACE {LANGUAGE_ALIAS} SCALAR SCRIPT "{{schema}}"."{{udf_name}}"() ' |
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.
I am not 100% sure, but shouldn't all parameters be enclosed only in single braces to allow f-string substitution?
f'CREATE OR REPLACE {LANGUAGE_ALIAS} SCALAR SCRIPT "{{schema}}"."{{udf_name}}"() ' | |
f'CREATE OR REPLACE {LANGUAGE_ALIAS} SCALAR SCRIPT "{schema}"."{udf_name}"() ' |
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.
This is a piece of code, which itself uses f-strings. This is the case for the schema
and udf_name
. In this code, the LANGUAGE_ALIAS
is a constant which we insert externally, also using an f-string. Basically, there is an external and internal f-string.
bucketfs_path=bucketfs_path, | ||
language_alias=slc_builder.language_alias) | ||
deployer.run(container_file=export_slc, alter_system=True, allow_override=True) | ||
def func(language_alias: str) -> None: |
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.
But I have some more questions:
- Could we make the function
func
use thelanguage_alias
that is already known to theslc_builder
? - Why does the fixture return a function instead of just uploading the SLC?
Co-authored-by: Christoph Kuhnke <[email protected]>
pytest-slc/README.md
Outdated
Here, we override the default `language_alias` fixture providing a "meaningful" name. The language container will be | ||
activated with this language alias. Note, that by default the test will run twice - once for each backend. |
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.
Here, we override the default `language_alias` fixture providing a "meaningful" name. The language container will be | |
activated with this language alias. Note, that by default the test will run twice - once for each backend. | |
The example test case overrides two fixtures that are used by fixture `deployed_slc` from this plugin: | |
* Fixture `language_alias` to provide a meaningful name. | |
* and fixture `slc_builder` to define the SLC to be used in the example test case. | |
The language container will be activated with value returned by fixture `language_alias`. | |
Note, that by default the test will run twice - once for each backend. |
closes #58