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

SNOW-893834 tests fix for Arrow #798

Closed
wants to merge 3 commits into from
Closed

Conversation

sfc-gh-dstempniak
Copy link
Collaborator

@sfc-gh-dstempniak sfc-gh-dstempniak commented Oct 20, 2023

Description

SNOW-893834 tests fix for Arrow

Checklist

  • Code compiles correctly
  • Code is formatted according to Coding Conventions
  • Created tests which fail without the change (if possible)
  • All tests passing (dotnet test)
  • Extended the README / documentation, if necessary
  • Provide JIRA issue id (if possible) or GitHub issue id in PR name

@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #798 (6260a69) into master (7f73791) will increase coverage by 0.47%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #798      +/-   ##
==========================================
+ Coverage   83.54%   84.01%   +0.47%     
==========================================
  Files          89       89              
  Lines        9146     9146              
  Branches      835      835              
==========================================
+ Hits         7641     7684      +43     
+ Misses       1278     1241      -37     
+ Partials      227      221       -6     

see 3 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@sfc-gh-dstempniak sfc-gh-dstempniak marked this pull request as ready for review October 24, 2023 07:42
@sfc-gh-dstempniak sfc-gh-dstempniak requested a review from a team as a code owner October 24, 2023 07:42
@@ -997,6 +1003,8 @@ public void TestGetDataTypeName()
// Act
using (DbDataReader reader = (DbDataReader)cmd.ExecuteReader())
{
ValidateResultFormat(reader);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this validation should be part of assert block

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure because it is not something we want to test, it's only validation of proper arrange/setup. But if you think it'd be more clear, I'll do it.

@@ -811,6 +815,8 @@ public void TestGetChar()
// Act
using (IDataReader reader = cmd.ExecuteReader())
{
ValidateResultFormat(reader);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this validation should be part of assert block

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you think about Assert.IsTrue(reader.Read()) ?
I think it should be in Act not Assert block. But if so, should we leave Assert.IsTrue(...) or just call reader.Read() ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ValidateResultFormat is a wraper for:

Assert.AreEqual(_resultFormat, ((SnowflakeDbDataReader)reader).ResultFormat);

which is definitely an assert.

If you want you could split Assert.IsTrue(reader.Read()) into something like :

// act
var read = reader.Read();

// assert
Assert.IsTrue(read);

you can split that. However I would not do it, because for me "act" block should be "execute query on the server and get the result" and that's cmd.ExecuteReader() and checking the result is rather a part of assert for me.

@@ -200,6 +200,8 @@ public void TestDateOutputFormat()
cmd.CommandText = $"select TO_DATE('2013-05-17')";
IDataReader reader = cmd.ExecuteReader();

ValidateResultFormat(reader);

Copy link
Collaborator

Choose a reason for hiding this comment

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

you could even remove this empty line since it is one of assertions


[ThreadStatic]
private static string t_directoryLogPath;
private string _directoryLogPath;
Copy link
Collaborator

Choose a reason for hiding this comment

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

what was wrong with the previous form of thread static? It didn't work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is no need to use static field so I removed it. Its because of: https://github.com/snowflakedb/snowflake-connector-net/actions/runs/6585609942/job/17892373465#step:8:4582

Copy link
Collaborator

Choose a reason for hiding this comment

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

This means that this test might be flaky. How your change is going to improve the situation? I think that the cause of the error is that we try to remove working directory after the test while logger has not flushed its logs to the file yet - or something like that. I don't see how your change will improve the situation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The process cannot access the file 'C:\Users\runneradmin\AppData\Local\Temp\easy_logging_logs_dkdsyynl.bgd\dotnet\snowflake_dotnet_k0201fjm.log' because it is being used by another process.
The problem might be connected with static field. Since there is no need to use static I changed it to private.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants