Releases: databrickslabs/pytester
Releases · databrickslabs/pytester
v0.5.0
- Added
make_run_as
fixture (#82). A new pytest fixture,make_run_as
, has been added to create an account service principal via theacc
fixture and assign it to a workspace with default permissions, which is removed after the test is complete. The fixture creates a service principal with a random display name and assigns it to the workspace. Users can optionally assign the service principal to account groups for specific actions using theaccount_groups
argument. The returned object contains properties for the workspace client, SQL backend, and SQL execution functions, as well as the display name and application ID of the ephemeral service principal. If desired, thews
fixture can be overridden to make all workspace fixtures provided by the plugin run as the ephemeral service principal, allowing for testing with lower privilege ephemeral service principals and improving security and isolation. This feature is not currently supported with Databricks Metadata Service authentication on Azure Databricks. - Bump codecov/codecov-action from 4 to 5 (#85). In this release, the Codecov GitHub Action has been updated from version 4 to 5, introducing several new features and changes. The new version uses the Codecov Wrapper to encapsulate the CLI, allowing for quicker updates to the Action. Additionally, version 5 includes an opt-out feature for tokens in public repositories, enabling contributors and other members to upload coverage reports without requiring access to the Codecov token. This can be accomplished by setting the ability for Codecov to receive a coverage report from any source in the Global Upload Token section of the settings page on codecov.io. Furthermore, the updated version introduces several new arguments, including
binary
,gcov_args
,gcov_executable
,gcov_ignore
,gcov_include
,report_type
, andskip_validation
, and changes thefile
andplugin
arguments tofiles
andplugins
, respectively. - Bump databrickslabs/sandbox from acceptance/v0.3.1 to 0.4.2 (#80). In this release, the
databrickslabs/sandbox
dependency has been updated from versionacceptance/v0.3.1
to0.4.2
. This update includes the addition of install instructions, more go-git libraries, and modifications to the README to explain how to use the library with thedatabricks labs sandbox
command. Dependency updates include golang.org/x/crypto from version 0.16.0 to 0.17.0. TheRun nightly tests
job in the workflow has also been updated to use the new version of thedatabrickslabs/sandbox/acceptance
image. The commit history for this release shows several commits, including the creation of "[TODO] XXX" issues and a full diff comparison. The pull request includes instructions for triggering Dependabot actions through comments. Reviewers are encouraged to thoroughly examine the changelog and commit history for more detailed information on the changes in this release. - Force keyword argument in
make_query
fixture (#81). In the latest update, themake_query
fixture in theredash.py
file has undergone changes to enhance code readability and maintainability. Thesql_query
parameter is now required to be passed as a keyword argument, preventing the possibility of it being mistakenly passed as a positional argument. Furthermore, thecreate
function's signature has been revised to include an explicit * before thesql_query
parameter. It is important to note that these changes have not affected the functionality of the method, but have instead altered the parameter passing style for improved clarity. This minor update is intended to elevate the overall quality of the codebase and promote best practices. - Renamed internal
notebooks
module toworkspace
(#86). In this release, the internalnotebooks
module has been renamed toworkspace
to better reflect its current functionality of managing and interacting with notebooks and other resources in a Databricks workspace. This renaming applies to the import statements inplugin.py
andtest_notebooks.py
, which has been renamed totest_workspace.py
. Additionally, import statements for making cluster policy and instance pool permissions have been added. The functionality of the imported functions, such asmake_directory
,make_workspace_file
,make_notebook
, andmake_repo
, remains unchanged. This change is part of the fix for issue #59 and aims to improve the clarity and consistency of the codebase. Software engineers adopting this project should update any imports or references to thenotebooks
module to use the newworkspace
module instead.
Dependency updates:
- Bump databrickslabs/sandbox from acceptance/v0.3.1 to 0.4.2 (#80).
- Bump codecov/codecov-action from 4 to 5 (#85).
Contributors: @dependabot[bot], @nfx, @JCZuurmond
v0.4.0
- Added Volume Fixture (#72). This commit introduces a Managed Volume fixture,
make_volume
, to the Unity Catalog in the test suite, facilitating the creation and use of a random volume for testing purposes. The fixture, when called without arguments, generates a volume with a random name. Alternatively, specifying thename
argument creates a volume with the given name, using theMANAGED
volume type, and associating it with a randomly generated catalog and schema. This promotes test isolation and prevents unintended interference. Additionally, this PR resolves issue #70 and includes unit and integration tests that have been manually verified to ensure the fixture's proper functioning. The commit also demonstrates a bug fix related to table retrieval in thetest_remove_after_property_table
test case.
Contributors: @christophergrant
v0.3.1
- Updated databrickslabs/sandbox requirement to acceptance/v0.3.1 (#64). In this pull request, we are updating the requirement for the
databrickslabs/sandbox
package to versionacceptance/v0.3.1
. This update is necessary to resolve any conflicts and ensure compatibility with the latest version of the package. The update includes several bug fixes, dependency updates, and the addition of install instructions in the changelog. The package also includes new git-related libraries and modifications to the README to explain how to use the package with thedatabricks labs sandbox
command. Additionally, there are dependency updates forgolang.org/x/crypto
in thego-libs
andruntime-packages
directories. Keeping dependencies up-to-date is important for taking advantage of new features and bug fixes, so it is recommended to merge this pull request and address any conflicts or issues that may arise. This update is generated by Dependabot, a tool used to keep dependencies up-to-date, and it will handle any conflicts as long as the pull request is not modified. Thedatabrickslabs/sandbox
package is used for building and testing the project. - Updating
make_schema
fixture to include location to create managed schema (#66). In this update, themake_schema
fixture has been enhanced to include an optionallocation
parameter, enabling users to specify the location for creating a managed schema. This change addresses issue #6 - [chore] update acceptance.yml and remove circular downstreads. In this release, the
acceptance.yml
file in the.github/workflows
directory has been updated to use theacceptance/v0.3.1
Docker image for theRun integration tests
job, replacing the previousacceptance/v0.2.2
version. This change ensures that the latest version of the integration tests are being run, which may include bug fixes, new features, and other improvements. Thetimeout
parameter has been removed from the job, which may result in longer test execution times but ensures that the tests have enough time to complete. Additionally, theARM_CLIENT_ID
andGITHUB_TOKEN
secrets are now passed as environment variables to the job. Thedownstreams.yml
file has also been updated to remove circular dependencies and streamline the build process, while maintaining the use of theubuntu-latest
runtime andfail-fast
option. TheRun nightly tests
job has been updated to use theacceptance/v0.3.1
Docker image, which may improve test execution during the nightly build due to potential bug fixes, new functionality, or better handling of timeout scenarios. Thecreate_issues
parameter remains set to true, ensuring that any test failures will result in the creation of GitHub issues to track them. These changes aim to improve the reliability and efficiency of the build and test processes.
Dependency updates:
- Updated databrickslabs/sandbox requirement to acceptance/v0.3.1 (#64).
Contributors: @nfx, @dependabot[bot], @HariGS-DB
v0.3.0
- Documentation: fix
make_query()
parameter name (#61). Themake_query()
fixture's documentation has been updated to correct the name of thequery
parameter tosql_query
. Thesql_query
parameter is used to specify the SQL query stored in the fixture, with the default value being "SELECT * FROM ". This change aims to enhance clarity and consistency in the naming of the argument, making it easier for users of themake_query()
fixture to comprehend its purpose and usage. By correcting the parameter name, the documentation provides a clearer and more consistent user experience. - Removed references to UCX (#56). This release includes changes to remove references to UCX in fixture names and descriptions within the testing process. The
create
function incatalog.py
now appends a random string to "dummy_t", "dummy_s", ordummy_c
for table, schema, and catalog names, respectively, instead of using "ucx_t", "ucx_S", and "ucx_C". Thetest_catalog_fixture
function has also been updated to replacedummy
withdummy_c
anddummy_s
for catalogs and schemas. Additionally, the description of a test query inredash.py
has been updated to remove the reference to UCX. Lastly, fixture names in the unit tests for a catalog have been updated to usedummy
instead of "ucx". These changes improve the independence of the testing process by removing technology-specific references, without affecting functionality. - Store watchdog tags in storage credentials comment (#57). In this release, the watchdog's behavior has been modified to retain properly tagged credentials when deleting them, as previously all credentials were removed without discrimination. This change introduces tagging for preserving specific credentials, and the
watchdog_remove_after
fixture has been added to the README file for documentation. Themake_storage_credential
fixture has been updated to include a new parameter,watchdog_remove_after
, which specifies the time at which the storage credential should be removed by the watchdog. Thecreate
function has been updated to accept this parameter and adds it as a comment to the storage credential. Theremove
function remains unmodified. The related fixtures section has been updated to include the newwatchdog_remove_after
fixture. This change was co-authored by Eric Vergnaud, but please note that it has not been tested yet. - [FEATURE] Extend
make_job
to runSparkPythonTask
(#60). Themake_job
fixture has been extended to support runningSparkPythonTask
in addition to notebook tasks. A newmake_workspace_file
fixture has been added to create and manage Python files in the workspace. Themake_job
fixture now supports SQL notebooks and files and includes atask_type
parameter to specify the type of task to run and aninstance_pool_id
parameter to reuse an instance pool for faster job execution during integration tests. Additionally, unit and integration tests have been added to ensure the proper functioning of the new and modified fixtures. These changes allow for more flexible and efficient testing of Databricks jobs with different task types and configurations. Themake_notebook
fixture has also been updated to accept acontent
parameter for creating notebooks with custom content. TheLanguage
enum from thedatabricks.sdk.service.workspace
module is used to specify the language of a notebook or workspace file.
Contributors: @JCZuurmond, @ericvergnaud, @asnare
v0.2.4
- Fixed PyPI metadata (#54). In this commit, the PyPI metadata for the pytester project has been updated with the new repository location at https://github.com/databrickslabs/pytester. The URLs for issues and source have been changed to point to the new repository, with the
issues
URL now directing to https://github.com/databrickslabs/pytester/issues and thesource
URL to https://github.com/databrickslabs/pytester. Furthermore, the versioning toolhatch
has been configured to manage the version number in the "src/databricks/labs/pytester/about.py" file. This ensures accurate and consistent versioning for the pytester project moving forward. - Improve
make_group
/make_acc_group
fixture consistency (#50). This PR introduces improvements to themake_group
andmake_acc_group
fixtures, designed for managing Databricks workspace groups. The enhancements include a double-check approach to ensure group visibility by requiring the group to be retrievable via both.get()
and.list()
calls. This mitigates, but does not entirely eliminate, consistency issues with the APIs used for managing groups. Thewait_for_provisioning
argument has been removed and replaced with an internal wait mechanism. The argument is still accepted but triggers a deprecation warning. Internal unit-test plumbing has been updated to use mock fixtures tailored for each test, ensuring double-check implementation testability. New and updated unit tests are included in thetest_iam.py
file, along with the introduction of the_setup_groups_api
function, which mocks specific clients to ensure group visibility when created. These changes improve consistency and reliability when working with Databricks workspace groups, making it easier for users to adopt the project.
v0.2.3
- Support providing name in
make_catalog
fixture (#52). Themake_catalog
fixture in our open-source library has been updated to allow users to specify a name for the catalog using a newname
parameter. Previously, the catalog was given a random name, but now users can have more control and customization over catalog names in their tests. This change includes updates to the docstring and the addition of unit tests to ensure the fixture behaves as expected with the new parameter. Additionally, the underlyingcall_stateful
function was updated to expect a callable that returns a generator of callables, enabling the support for providing a name. Thetest_make_catalog_creates_catalog_with_name
andtest_make_catalog
tests have been added to verify the behavior of the fixture with the newname
parameter.
Contributors: @asnare, @JCZuurmond
v0.2.2
- Use watchdog timeout to catalog properties (#48). This pull request introduces a new
RemoveAfter
property for catalogs, which allows for marking them for skipping by the watchdog. This change addresses the current implementation gap, which does not explicitly indicate when catalogs are being used. The new property will specify the time from which objects can be purged. A corresponding fixturewatchdog_remove_after
has been added to the list of available fixtures, and themake_catalog
fixture has been updated to include this new property. Additionally, a timeout mechanism for catalogs has been implemented, which improves the system's efficiency and safety by marking catalogs as in use. A test for themake_catalog
function has been included to ensure that theRemoveAfter
entry is correctly added to the catalog properties. However, the specific call parameters for thecatalogs.create
method cannot be accurately determined in the test. - use tags instead of name suffix for queries (#47). This release introduces updates to the testing library for Databricks, enhancing the naming conventions for queries to improve readability and comprehension. The previous implementation used name suffixes, which have been replaced with watchdog query tags. The
watchdog_purge_suffix
fixture has been renamed towatchdog_remove_after
, and the newmake_query
fixture has been added to the documentation. In addition, themake_query
andcreate
functions now accept an optionaltags
argument, and the query name is generated with a unique identifier. Iftags
are provided, theRemoveAfter
tag is added. Theoriginal_query_tag
is no longer hardcoded in thecreate
function and has been removed. These changes improve the overall user experience and maintainability of the project.
Contributors: @ericvergnaud
v0.2.1
- Moved remaining UCX integration tests and fixtures (#45). In this release, we have made significant changes to the UCX integration tests and fixtures, as indicated by multiple commit messages. Firstly, we have moved remaining UCX integration tests and fixtures, introducing a new PyTest fixture called
Installation
in the README.md file, providing instructions on how to adddatabricks-labs-pytester
as a test-time dependency when usinghatch
as the build system. Additionally, we have added themake_feature_table
fixture, which creates a Databricks feature table and cleans it up after the test, taking optional parameters for customization. We have also modified themypy
configuration in thepyproject.toml
file to allow untyped imports during the type-checking process. In thecompute.py
file, we have updated themake_job
fixture to return a function that creates adatabricks.sdk.service.jobs.Job
instance, and modified thecreate
function to return thedatabricks.sdk.service.jobs.Job
instance directly. We have also added a new fixture calledmake_feature_table
in the plugin file, which simulates the lifecycle of a feature table in the machine learning service, with functions to generate a unique name and create/remove the feature table. In thetest_catalog.py
file, we have made changes to clean up the file and ensure proper logging of test events and errors. Overall, these changes aim to refactor, expand functionality, and improve user-friendliness for the adopters of the project, ensuring proper logging and debugging capabilities. - [internal] port over existing UCX integration tests (#44). Three new integration tests have been added to the UCX project to verify the functionality of the
RemoveAfter
property for tables and schemas. Thetest_remove_after_property_table
andtest_remove_after_property_schema
tests create new tables and schemas, respectively, and check if theRemoveAfter
property is included in their properties. However, these tests are still marked asTODO
due to existing issues with thetables.get
andschemas.get
functions. In addition, existing UCX integration tests have been ported over, which include new functions for testing the removal of resources based on theRemoveAfter
tag. These tests are located in thetests/integration/fixtures/test_compute.py
file and test the removal of various types of resources, including jobs, clusters, warehouses, and instance pools. The tests ensure that the time until purge is less than theTEST_RESOURCE_PURGE_TIMEOUT
value plus one hour and import thedatetime
module and theTEST_RESOURCE_PURGE_TIMEOUT
constant from thewatchdog
fixture, as well as thelogging
anddatabricks.sdk.service.iam
modules.
Contributors: @nfx
v0.2.0
- Added
acc
andmake_acc_group
fixtures (#42). In this release, we have added two new fixtures,acc
andmake_acc_group
, to the open-source library. Theacc
fixture provides a Databricks AccountClient object for use in tests, which can interact with the Databricks account API and automatically determines the account host from theDATABRICKS_HOST
environment variable. Themake_acc_group
fixture is used for managing Databricks account groups, creating them with specified members and roles, and automatically deleting them after the test is complete. This fixture mirrors the behavior of themake_group
fixture but interacts with the account client instead of the workspace client. These fixtures enable more comprehensive integration tests for theacc
object and its various methods, enhancing the testing and management of Databricks account groups.
Contributors: @nfx
v0.1.1
- Fixed nightly CI builds (#40). In this release, we have removed the
no-cheat
GitHub Actions workflow that checked for disables pylint directives in new code. We have also updated the pytest requirement version to ~8.3.3 and added badges for Python version support and lines of code to the README file. Thepermissions.py
file in thedatabricks/labs/pytester/fixtures
directory has been updated to fix nightly CI builds by improving import statements and updating types. TheSqlPermissionLevel
class has been imported from thedatabricks.sdk.service.sql
module, and an existing test case has been updated to use this new permission level for SQL-specific queries. Additionally, we have updated the version constraints for three dependencies in thepyproject.toml
file to allow for more flexibility in selecting compatible library versions. These changes may simplify the project's GitHub Actions workflows, reduce maintenance overhead, and enhance the testing process and code quality.
Contributors: @nfx