Skip to content
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

Testflows -> Pytest #454

Merged
merged 14 commits into from
Oct 2, 2024
Merged

Testflows -> Pytest #454

merged 14 commits into from
Oct 2, 2024

Conversation

slvrtrn
Copy link
Contributor

@slvrtrn slvrtrn commented Sep 13, 2024

  • Refactored most of the tests from testflows to pytest, which is much more convenient to run from the PyCharm IDE and, hopefully, clearer
  • Added pytest run to the CI
  • Removed all python stuff from CMakeLists
  • Added a docker-compose file with ClickHouse
  • Minimal CONTRIBUTING.md (to be updated in the follow-ups)

TODO (follow-ups):

  • Tests will nullable types - see FIXME in the code, None binds as '' and the rendered queries have weird casts to String/LowCardinality(String).

    Sample error:

    Attempt to read after eof: while converting '' to UInt8. (ATTEMPT_TO_READ_AFTER_EOF)
    

    Sample rendered query:

    SELECT * FROM test_sanity_simple_data_types 
    WHERE ni = _CAST(NULL, 'Nullable(String)') 
    ORDER BY i ASC, s ASC, d ASC
    

    instead of

    SELECT * FROM test_sanity_simple_data_types
    WHERE ni = NULL 
    ORDER BY i ASC, s ASC, d ASC
    

    which is still incorrect, though. Should be actually rendered as:

    SELECT * FROM test_sanity_simple_data_types
    WHERE isNull(ni)
    ORDER BY i ASC, s ASC, d ASC
    
  • Salvage the useful tests from the root test.py and test.sh files and make them using pytest, too

  • Cleanup the test dir

@alesapin
Copy link
Member

#452 (comment) Thank you, please replace them all with pytest.

@slvrtrn slvrtrn marked this pull request as ready for review September 17, 2024 17:39
# Array
# Tuple
# Map
# LowCardinality
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that in the deleted regression.py, nullable tests are also marked as expected failure.
However, most of the data types tests that were "not supported" actually work, and implemented now.

@@ -30,9 +30,6 @@ RUN apt-get update -y \
libssl-dev \
Copy link
Contributor Author

@slvrtrn slvrtrn Sep 17, 2024

Choose a reason for hiding this comment

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

Probably this Dockerfile should be removed entirely (in the follow-up).

"toDateTime64('2020-03-25 12:11:22.123456789', 9, 'Asia/Kathmandu')", SQL_TYPE_TIMESTAMP,
"2020-03-25 09:26:22.123456789", SQL_TIMESTAMP_STRUCT{2020, 3, 25, 9, 26, 22, 123456789}
"2020-03-25 06:26:22.123456789", SQL_TIMESTAMP_STRUCT{2020, 3, 25, 6, 26, 22, 123456789}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adjusted for the clickhouse server running in docker with default UTC timezone

@@ -1,100 +0,0 @@
name: Build and Test - Docker
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed as I am not sure what is the point of this. The tests are executed without this test runner.

@@ -16,6 +16,7 @@
is_python_3 = (sys.version_info.major == 3)
is_windows = (os.name == 'nt')


Copy link
Contributor Author

@slvrtrn slvrtrn Sep 17, 2024

Choose a reason for hiding this comment

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

to be revisited and rewritten in pytest in a follow-up, if necessary

the same with test.sh - it executes a lot of queries, but never asserts the output.

@@ -107,7 +100,7 @@ jobs:
-DTEST_DSN_LIST="ClickHouse DSN (ANSI);ClickHouse DSN (Unicode);ClickHouse DSN (ANSI, RBWNAT)"

- name: Build
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }}
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }} --parallel $(nproc)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

speeds up the build by a few minutes

@@ -122,94 +115,96 @@ jobs:
# However, these binaries are uploaded to be available in GH's 'Actions', just in case.
- name: Upload the artifacts
if: ${{ matrix.compiler == 'GCC' && matrix.odbc_provider == 'UnixODBC' && matrix.build_type == 'Release' && matrix.runtime_link == 'dynamic-runtime' && matrix.third_parties == 'bundled-third-parties' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed outdated Node.js warning

docker pull ${CLICKHOUSE_SERVER_IMAGE}
docker run -d --name clickhouse ${CLICKHOUSE_SERVER_IMAGE}
docker ps -a
docker stats -a --no-stream
Copy link
Contributor Author

@slvrtrn slvrtrn Sep 17, 2024

Choose a reason for hiding this comment

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

The CI uses docker-compose for that now, so it's more convenient locally as well.

run: |
export ODBCSYSINI=
export ODBCINSTINI="${{ github.workspace }}/run/.odbcinst.ini"
export ODBCINI="${{ github.workspace }}/run/.odbc.ini"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably should have been made a bit cleaner and extracted into some "generate env variables" step, but it works. Note the empty ODBCSYSINI (mentioned in the contribution guide now, too).

Feature(run=parameterized, flags=TE)

if main():
xfails = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the expected failures here.

@slvrtrn
Copy link
Contributor Author

slvrtrn commented Sep 17, 2024

It should be "mergeable," I think. Added some comments to make the review a bit easier.

"toDateTime64('2020-03-25 12:11:22.123456789', 9, 'Asia/Kathmandu')", SQL_TYPE_TIMESTAMP,
"2020-03-25 09:26:22.123456789", SQL_TIMESTAMP_STRUCT{2020, 3, 25, 9, 26, 22, 123456789}
"2020-03-25 06:26:22.123456789", SQL_TIMESTAMP_STRUCT{2020, 3, 25, 6, 26, 22, 123456789}
}/*,

// TODO: uncomment once the target ClickHouse server is 21.4+
Copy link
Member

Choose a reason for hiding this comment

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

should be uncommented now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it still does not work :)

# After the fix, Nullable test cases should be re-added
# Sample error: Attempt to read after eof: while converting '' to UInt8. (ATTEMPT_TO_READ_AFTER_EOF)
#
# TODO:
Copy link
Member

Choose a reason for hiding this comment

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

Should we create a separate task to track these test improvements?

@slvrtrn
Copy link
Contributor Author

slvrtrn commented Sep 19, 2024

@alesapin, can you please confirm that

  1. it works on your machine
  2. CMakeLists changes are ok (there are no more Python invocations there)

After that, we can merge the branch.

Copy link
Member

@alesapin alesapin left a comment

Choose a reason for hiding this comment

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

If it's possible let's fix timezone issue.

@slvrtrn slvrtrn merged commit 1996aba into master Oct 2, 2024
38 of 46 checks passed
@slvrtrn slvrtrn deleted the pytest branch October 2, 2024 14:03
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